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 =
Ïà¹ØÎĵµ£º
JAXB¸ÅÒª
JAXBΪJava Architecture for XML BindingµÄËõд£¬ÒâΪXML°ó¶¨µÄJAVA¿ò¼Ü¡£ËüÌṩÁËÒ»Ì׿ÉÒÔ¼òµ¥´æÈ¡XMLÊý¾ÝµÄAPI£¬Í¬Ê±£¬JAXB¿ÉÒÔ¸ù¾ÝXMLµÄschema×Ô¶¯Éú³É²Ù×÷XMLµÄJAVAÀà¡£ÀûÓÃJAXB£¬Ê¹ÓÃJAXB×Ô¶¯Éú³ÉµÄ²Ù×÷XMLµÄJAVAÀ࣬¿ÉÒÔ»ù±¾Éϲ»Óÿ¼ÂÇXML½á¹¹¶ø¼òµ¥µØ´æÈ¡XMLÊý¾Ý¡£
JAXBµÄÏÂÔØÓë°²×°
JAXBÖÁÉÙÐèÒªµ¼ÈëÒ ......
xsdÓëxmlºÍÀà(class)¶ÔÏóÖ®¼äµÄ»¥Ïàת»»
.
µÚÒ»£ºÍ¨¹ýÏÖÓеÄÒѾдºÃµÄxsdÀ´Éú³Éclass£¨.cs£©Îļþ¡£
ÔÚÄúVisual StudioµÄ°²×°Ä¿Â¼ÏµÄSDKv2.0BinÖÐÓиöÓ¦ÓóÌÐòxsd.exe£¨Í¨¹ýÕâ¸öÓ¦ÓóÌÐò¿ÉÒÔʹÓÃxsdÀ´´´½¨ÀàÎļþ£©¡£
¾ßÌå²Ù×÷£ºÍ¨¹ý´ò¿ªVisual Studio ÃüÁîÌáʾ£¬¿ÉÒÔÊäÈëxsdÖ¸ÁîÀ´²é¿´Ò»Ð©¾ßÌåµÄ²Ù×÷Ö¸ÁîµÄÓô¦£¬È»ºó ......
XmlÎļþ²Ù×÷ºÍÎļþ²Ù×÷(FileInfoÀà)
1. ÉÏ´«Îļþ
¡¡2. дXmlÎļþ
3. Îļþ¿½±´
¡¡1.¡¡//ÉÏ´«
protected void picUp_Click(object sender, EventArgs e)
{
......
ʹÓÃXmlDocumentÀàÍê³É¶ÔXMLµÄ²é¡¢É¾¡¢Ìí¡¢¸Ä
http://www.aspdiy.net/article/53.htm
ºǫ́C#´úÂë
1using System;
2using System.Collections;
3using System.ComponentModel;
4using System.Data;
5using System.Drawing;
6using System. ......