首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >从xpathnavigator中提取xml属性值

从xpathnavigator中提取xml属性值
EN

Stack Overflow用户
提问于 2013-05-24 01:47:53
回答 1查看 1.3K关注 0票数 0

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

代码语言:javascript
复制
        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**"
EN

回答 1

Stack Overflow用户

发布于 2013-05-24 01:52:48

您尝试过GetAttribute方法吗?

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

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/16720602

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档