【发布时间】:2017-01-17 04:30:42
【问题描述】:
下面是我的 XML:
<Profile>
<_nObjectID>1</_nObjectID>
<_sObjectName>ABC</_sObjectName>
<_sObjectType>10</_sObjectType>
</Profile>
<Profile>
<_nObjectID>2</_nObjectID>
<_sObjectName>DEF</_sObjectName>
<_sObjectType>20</_sObjectType>
</Profile>
<Profile>
<_nObjectID>3</_nObjectID>
<_sObjectName>GHI</_sObjectName>
<_sObjectType>50</_sObjectType>
</Profile>
我想知道这组配置文件中 _nObjectID=2 的 _sObjectName 是什么。我们如何使用 XPath 找到它?
到目前为止,我尝试了以下方法:
string name = productsXML.XPathSelectElement("//Profile/_nObjectID").Value;
但结果只是给了我_nObjectID。如何在这个_nObjectID下得到它的_sObjectName?
【问题讨论】:
标签: c# xml visual-studio xpath