从xpathnavigator中提取XML属性值
本文关键字:属性 XML 提取 xpathnavigator | 更新日期: 2023-09-27 18:15:16
我试图通过以下代码获得基于州名的州代码:
XPathDocument document = new XPathDocument("D:/Sample.xml");
XPathNavigator navigator = document.CreateNavigator();
XPathNavigator node = navigator.SelectSingleNode("//WorldCountry/Country/states/states[@name='Maharastra']");
string statescode=node.Attributes.GetNamedItem("code").Value
But I am getting error in list line saying that "**XPathNavigator** does not contain a defination of **Attributes**"
您尝试过GetAttribute
方法吗?