我找到了一些关于这个主题的例子。一些示例给出了使用SelectNodes()
or修改属性SelectSingleNode()
的方法,而其他示例给出了使用 修改属性的方法someElement.SetAttribute("attribute-name", "new value");
但是我仍然很困惑,如果我只使用 a ,如何建立关系XpathNodeItterator it
?
假设我定义如下,
System.Xml.XPath.XPathDocument doc = new XPathDocument(xmlFile);
System.Xml.XPath.XPathNavigator nav = doc.CreateNavigator();
System.Xml.XPath.XPathNodeIterator it;
it = nav.Select("/Equipment/Items/SubItmes");
while (it.MoveNext())
{
name = it.Current.GetAttribute("name ", it.Current.NamespaceURI);
int vidFromXML = int.Parse(it.Current.GetAttribute("vid", it.Current.NamespaceURI));
if (vidFromXML = vid)
{
// How can I find the relation between it and element and node? I want to modify name attribute value.
}
}
有没有类似的方法it.setAttribute(name, "newValue")
?