Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/xpath/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Xml 根据同一级别的值在XPath中选择值_Xml_Xpath_Xpath 1.0 - Fatal编程技术网

Xml 根据同一级别的值在XPath中选择值

Xml 根据同一级别的值在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>

我得到了这个部分XML

 <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