Xpath:根据其他属性的值选择属性

时间:2014-07-11 14:40:10

标签: xml xpath xpath-1.0

我有[部分] XML:

   <Events>
     <Properties>
       <Property Descriptor=100>1378314024</Property>
       <Property Descriptor=200>ABC1234</Property>
     </Properties>
     <Properties>
       <Property Descriptor=100>1378314022</Property>
       <Property Descriptor=200>123456</Property>
     </Properties>
     <Properties>
       <Property Descriptor=100>1378314023</Property>
       <Property Descriptor=200>123456</Property>
     </Properties>
    </Events>

如何在@Property Descriptor="100"上第一次出现123456时选择@Property Descriptor="200"

1 个答案:

答案 0 :(得分:1)

你可以这样做:

(//Properties[Property[@Descriptor='200'][.='123456']]/Property[@Descriptor='100'])[1]