如何获取XmlNode中的文本?见下:如何在XmlNode中获取文本
XmlNodeList nodes = rootNode.SelectNodes("descendant::*");
for (int i = 0; i < nodes.Count; i++)
{
XmlNode node = nodes.Item(i);
//TODO: Display only the text of only this node,
// not a concatenation of the text in all child nodes provided by InnerText
}
而我最终想要做的是prepend“HELP:”到每个节点的文本。
'ChildNodes'是一个'XmlNodeList',它实现了'IEnumerable'的非泛型版本。因此,您需要在上面的循环中明确说明“child”的类型,即“foreach(node.ChildNodes中的XmlNode子节点)”。 – LeopardSkinPillBoxHat 2015-07-13 03:30:17
@LeopardSkinPillBoxHat:已修复,谢谢。 – 2015-07-13 05:52:17