【发布时间】:2012-10-14 22:59:41
【问题描述】:
<feed>
<entry>
<data>1234</data>
<content>Stackoverflow</content>
</entry>
</feed>
Next data..
我必须在 c# 中使用 xpath 创建上面的 xml 是否可以这样做..
我已经使用下面的代码完成了 xml 文件
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(@"C:\Log_Data.xml");
XmlElement newelement = xmlDoc.CreateElement("entry");
XmlElement xmldata = xmlDoc.CreateElement("data");
XmlElement xmlcontent = xmlDoc.CreateElement("content");
xmldata.InnerText ="1234" ;
xmlcontent.InnerText ="Stackoverflow";
newelement.AppendChild(xmldata);
newelement.AppendChild(xmlcontent);
xmlDoc.DocumentElement.AppendChild(newelement);
xmlDoc.Save(@"C:\Log_Data.xml");
但我必须像在 sql 中那样使用 Xpath 来编写查询 “插入表格......” .Net 2.0 中应该可以吗
【问题讨论】:
标签: c# .net xslt xpath .net-2.0