更新时间:2023-01-30 20:54:00
这是一种最简单的方法,可以在节点上使用 for 循环来获取每个节点中的信息.使用 node.ChildNodes 属性来获取 chilenodes.
This is easiest way one can use for loops on nodes to get the information in each node. use node.ChildNodes property to get the chilenodes.
XmlDocument doc = new XmlDocument();
doc.Load("filepath");
//Here Path could be- "//ElementType" ---> this will give all nodes with name ElementType
XmlNodeList nodes= doc.SelectNodes("//give path of nodes you want attributes for");
foreach (XmlNode node in nodes)
{
//Assuming you want information of element tags
foreach (XmlNode child in node.ChildNodes)
{
string name= node.Attributes["type"].Value;
string name= node.Attributes["label"].Value;
}
}