[英]XML Xpath Query
I have been converting some VB.Net XMl code to read specific XML by Elements as opposed to attribute values, and I have the following line that has stumped me: 我一直在转换一些VB.Net XMl代码以通过Elements读取特定的XML,而不是属性值,并且下面一行让我很困惑:
Dim fNode As XmlNodeList = x.SelectNodes(String.Format("tables
/table
/field[
@pkid='{0}'
]", fk))
My questions is regarding the end part, how do I write that to check an elements value as opposed to the specific attribute? 我的问题是关于末尾部分的,我该如何编写以检查元素值而不是特定属性? The specific element that I want to check is
<PK>
and I want to evaluate it against fk. 我要检查的特定元素是
<PK>
,我想根据fk对其进行评估。
Thanks. 谢谢。
tables/table/field[PK='{0}']
There is nothing special about attributes in this context - you can test against the value of the PK
element just as easily by simply removing the @
. 在这种情况下,属性没有什么特别的-您只需删除
@
就可以轻松地对PK
元素的值进行测试。
Example input xml: 输入xml示例:
<tables>
<table>
<field>
<PK>42</PK>
<!-- Other fields -->
</field>
</table>
</tables>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.