Xml Manipulation

在java中,处理XML用jdom挺好用的。

在C#中,有类似的类,而不需要用Navigator:

XmlTextReader reader=new XmlTextReader(FILE_NAME);
XmlDocument doc=new XmlDocument();
doc.Load(reader); // 注意Load和LoadXml的区别,后者的参数为Xml片段
reader.Close();

XmlElement root=doc.DocumentElement;
XmlNode node=root.SelectSingleNode("//char[@id=1234");
node.Attributes["id"].Value="4321";
doc.Save(FILE_NAME);
posted @ 2010-10-02 20:42  irischan  阅读(316)  评论(1编辑  收藏  举报