0

我正在尝试通过以下代码获取基于州名的州代码:

        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**"
4

1 回答 1

0

你试过这个GetAttribute方法吗?

http://msdn.microsoft.com/en-us/library/system.xml.xpath.xpathnavigator.getattribute.aspx

于 2013-05-23T17:52:48.337 回答