2017-08-11 32 views
1

我有下面的XML,我希望能夠去哪裏類型值= 1XPath表達式得到一個值基於其它值

我曾嘗試很多不同的場景的電話值並得到以下; //Telephone/type[text()='1']/parent::tel但這是行不通的。請有人幫忙。

<Telephone> 
    <Number> 
     <tel>01242123456</tel> 
     <CountryCode>GB</CountryCode> 
     <CountryDiallingCode>+44</CountryDiallingCode> 
    </Number> 
    <type>1</type> 
</Telephone> 
<Telephone> 
    <Number> 
     <tel>07777777777</tel> 
     <CountryCode>GB</CountryCode> 
     <CountryDiallingCode>+44</CountryDiallingCode> 
    </Number> 
    <type>3</type> 
</Telephone> 

回答

1

試試看 //電話[類型= '1'] /數字/電話

+0

完美!非常感謝。 :) – TestingHut