【发布时间】:2011-10-31 08:12:09
【问题描述】:
使用通过 XmlDocument 的旧方式,
string xmlstring = "<root><profile><Name>John</Name><Age>23</Age></profile></root>";
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.LoadXml(xmlstring);
string childNodes = xmlDoc.SelectSingleNode("root/Profile").InnerXml;
// output of childNodes would be => "<Name>John</Name><Age>23</Age>";
当您有 XElement 变量时,在 LinQ 中执行上述执行的等价物是什么。我在 XElement 中看到 XPathSelectElement 方法,但它不返回子节点 + 子节点文本。有什么想法吗?
【问题讨论】:
-
为什么要获取
InnerXml?之后你想用它做什么?
标签: c# xml linq linq-to-xml