linq to xml(MOSS GetCurrentUser)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Xml;
using System.IO;
using System.Data;
using System.Data.Linq;
namespace XmlGetUserInfo
{
public class GetUser:WebPart
{
SPWeb sWeb;
SPUser currUser;
private string AddUser()
{
sWeb = SPControl.GetContextWeb(Context);
currUser = sWeb.CurrentUser;
XElement employees = null;
StringBuilder user = new StringBuilder();
//create and writer xml
//string strFilename = Environment.CurrentDirectory + @"\txtuser.xml";//get filename
string strFilename = System.AppDomain.CurrentDomain.BaseDirectory + @"\txtuser.xml";
if(!File.Exists(strFilename))
{
XmlWriterSettings xws=new XmlWriterSettings();
xws.OmitXmlDeclaration=true;
using (XmlWriter writer = XmlWriter.Create(strFilename,xws))
{
employees = new XElement("Root",
new XElement("Employee",
new XElement("Name", currUser.Name), new XElement("Email", currUser.Email)
)
);
employees.Save(writer);
}
}
else
{
employees = XElement.Load(strFilename);
XElement tree=new XElement("Root",
new XElement("Employee",
new XElement("Name", currUser.Name), new XElement("Email", currUser.Email)),
from el in employees.Elements()
select el);
TextReader tr = new StringReader(tree.ToString());
XElement xel =
Ïà¹ØÎĵµ£º
ID.xml
<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/css" href="ID.css"?>
<bookdetail>
<book class="A" id="B1">
<author>²ÜÑ©ÇÛ</author>
<title>ºìÂ¥ÃÎ</title>
<price>60.00</price>
</book>
<book class="A ......
xmlpost by HttpWebRequest:
protected string PostXmlToURL(string url,string data)
{
HttpWebRequest hwr = (HttpWebRequest)HttpWebRequest.Create(url);
hwr.Method = "POST";
Stream stream = hwr.GetRequestStream();
StreamWri ......
ʲôÊÇXML£¿
XML ´ú±íExtensible Markup Language£¨eXtensible Markup LanguageµÄËõд£¬ÒâΪ¿ÉÀ©Õ¹µÄ±ê
¼ÇÓïÑÔ£©¡£XMLÊÇÒ»Ì׶¨ÒåÓïÒå±ê¼ÇµÄ¹æÔò£¬ÕâЩ±ê¼Ç½«Îĵµ·Ö³ÉÐí¶à²¿¼þ²¢¶ÔÕâЩ²¿¼þ¼ÓÒÔ±êʶ¡£
ËüÒ²ÊÇÔª±ê¼ÇÓïÑÔ£¬¼´¶¨ÒåÁËÓÃÓÚ¶¨ÒåÆäËûÓëÌض¨ÁìÓòÓйصġ¢ÓïÒåµÄ¡¢½á¹¹»¯µÄ±ê¼ÇÓïÑԵľ䷨ÓïÑÔ¡£
&n ......
×î½ü¹¤×÷ÄÚÈÝÐèÒª¶ÔJava¶ÔÏó×öXMLÊä³ö£¬¹«Ë¾Àï³£ÓõÄÁ½ÖÖ¿ò¼ÜÊÇXStreamºÍXML Beans¡£Á½ÖÖ¶¼ÎÒ¶¼ÓÃÁË£¬¶ÔÓÚÆÕͨµÄ£¬schema²»ÊǺܸ´ÔÓµÄXMLÎļþÀ´ËµÑ¡ÔñXStream¸ü·½±ã¡£ÕâƪÎÄÕÂÏȽéÉÜÒ»ÏÂXStreamµÄÓ÷¨£¬XML BeansµÄÓ÷¨ÁíÍâÔÙ½éÉÜ¡£
1. Ïȸø¸öÒªÊä³öµÄxmlÎĵµµÄÀý×Ó£º
<students>
<student>
&l ......
ͨ³£Çé¿öÏÂ,ÔÚJAX-WS2.0ÖÐÊÇÀûÓÃJAXB½«´«ÈëµÄSOAP XMLÏûϢת»»³ÉJAVAµÄobject,È»ºóµ÷ÓöÔÓ¦porttypeµÄJAVAÀàµÄÏàÓ¦µÄ·½·¨,ÔÚÍê³Éµ÷Óúó,ÔÙͨ¹ýJAXB½«·µ»Ø²ÎÊýת³ÉSOAP XML.
JAX-WS»¹ÌṩÁËÁíÒ»ÖÖ·½·¨,ÈÃÎÒÃÇ¿ÉÒÔÖ±½Ó²Ù×÷SOAP XML,ͨ¹ýÈöÔÓ¦porttypeµÄJAVAÀàʵÏÖ Provider<Source>½Ó¿Ú,µ±·þÎñÆ÷¶ËÊÕµ½SOAPÏûÏ¢ºó,»áµ ......