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 =
相关文档:
2010-05-19
七、转换XML
l 可扩展样式表语言(XSL),被定义成了一种表示样式表的语言。是管理怎样从格式A转换一个文档到格式B的规范语言。该语言组件用于管理转换结构中的处理和身份验证
n XSL是一种用来转换XML文档的语言。
n XSL是一个用来指定XML文档格式的词汇库。
l XSL和树形描述:这 ......
这是一篇讲解如何使用XML实现Flash与通信的入门级实例教程。通过本例的学习,我们将了解使用XML开发Flash RIAs的基本流程。
从Flash Player 5开始,就可以使用XML对象来实现Flash与后台通信。Flash浏览器与XML数据之间的直接进行数据交换,并且同LoadVars函数一样,都是以字符串形式传递的。后台语言作为XML数据和数据库 ......
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 ......
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(@"E:\大二下\xml\province.xml");
会提示出现以下错误
http://hi.csdn.net/attachment/201005/24/0_1274703276Ld6I.gif
麻烦各位帮忙看看,谢谢了 ......