我想遍历 XML 文件中的所有节点并打印它们的名称。
做这个的最好方式是什么?我正在使用.NET 2.0。
您可以使用Xml文档。一些 XPath 也很有用。
只是一个简单的例子
XmlDocument doc = new XmlDocument();
doc.Load("sample.xml");
XmlElement root = doc.DocumentElement;
XmlNodeList nodes = root.SelectNodes("some_node"); // You can also use XPath here
foreach (XmlNode node in nodes)
{
// use node variable here for your beeds
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)