摘要: C# 用Linq的方式实现对Xml文件的基本操作(创建xml文件、增删改查xml文件节点信息)http://www.cnblogs.com/mingmingruyuedlut/archive/2011/01/27/1946239.html修改了一下里面一部分 try{//定义并从xml文件中加载节点(根节点)XElementrootNode=XElement.Load(xmlPath);varquery=fromrssFeedinrootNode.Descendants("User")selectnew{name=rssFeed.Element("name&quo 阅读全文
posted @ 2011-04-18 18:29 韩天伟 阅读(366) 评论(0) 推荐(0)
摘要: 将一个已知的XML放到XDocument 对象当中使用LINQ 查询非常的容易,下面是一个例子。查找XML文档中的所有PERSONA元素显示结果个数,并遍历输出其值publicvoidMyDescendants(){XDocumentxdoc=XDocument.Load(Server.MapPath("hamlet.xml"));//查找元素名为PERSONA的元素varquery=frompeopleinxdoc.Descendants("PERSONA")selectpeople.Value;//people是符合条件元素结果集而people.Va 阅读全文
posted @ 2011-04-18 18:17 韩天伟 阅读(445) 评论(0) 推荐(0)