Xml 根据同一级别的值在XPath中选择值
我得到了这个部分XMLXml 根据同一级别的值在XPath中选择值,xml,xpath,xpath-1.0,Xml,Xpath,Xpath 1.0,我得到了这个部分XML <Events> <Properties> <Property Descriptor="1">VALUE1</Property> <Property Descriptor="2">FOO</Property> <Property Descriptor="3">BAR</Property> </Properties>
<Events>
<Properties>
<Property Descriptor="1">VALUE1</Property>
<Property Descriptor="2">FOO</Property>
<Property Descriptor="3">BAR</Property>
</Properties>
<Properties>
<Property Descriptor="1">VALUE2</Property>
<Property Descriptor="2">NO</Property>
<Property Descriptor="3">NOTHINGHERE</Property>
</Properties>
</Events>
价值1
福
酒吧
价值2
不
什么都没有
嗨,当Property Descriptor=“2”=“FOO”时,我可以查询Property Descriptor=“3”的第一个匹配项吗?这里的结果应该是BAR
我尝试了//Properties/Property[@Descriptor=“3”][..//Property[@Descriptor=“2”]=“FOO”]
,但它现在可以工作了
当Property Descriptor=“2”=“FOO”时,我是否可以查询Property Descriptor=“3”的第一个匹配项
更详细地说:
/Events/Properties Look for a Properties element
[Property but only if it has a Property element
[@Descriptor = '2'] = 'FOO'] but only if its Descriptor attribute equals 2 and
its textual content is "FOO"
/Property[@Descriptor = '3'] for that Properties element look for a child element
called Property where the Descriptor attribute equals 3
[1] thereof return the first occurrence
当Property Descriptor=“2”=“FOO”时,我是否可以查询Property Descriptor=“3”的第一个匹配项
更详细地说:
/Events/Properties Look for a Properties element
[Property but only if it has a Property element
[@Descriptor = '2'] = 'FOO'] but only if its Descriptor attribute equals 2 and
its textual content is "FOO"
/Property[@Descriptor = '3'] for that Properties element look for a child element
called Property where the Descriptor attribute equals 3
[1] thereof return the first occurrence
当Property Descriptor=“2”=“FOO”时,我是否可以查询Property Descriptor=“3”的第一个匹配项
更详细地说:
/Events/Properties Look for a Properties element
[Property but only if it has a Property element
[@Descriptor = '2'] = 'FOO'] but only if its Descriptor attribute equals 2 and
its textual content is "FOO"
/Property[@Descriptor = '3'] for that Properties element look for a child element
called Property where the Descriptor attribute equals 3
[1] thereof return the first occurrence
当Property Descriptor=“2”=“FOO”时,我是否可以查询Property Descriptor=“3”的第一个匹配项
更详细地说:
/Events/Properties Look for a Properties element
[Property but only if it has a Property element
[@Descriptor = '2'] = 'FOO'] but only if its Descriptor attribute equals 2 and
its textual content is "FOO"
/Property[@Descriptor = '3'] for that Properties element look for a child element
called Property where the Descriptor attribute equals 3
[1] thereof return the first occurrence