2017-10-19 97 views
1

獲取價格下所有節點所需的Xpath代碼是什麼?XPath評估失敗

到目前爲止,我已嘗試AMUpdate/AMMesageType/amprice/Price,這是失敗。

<AMUpdate> 
    <AMMessageType>AMPRICES</AMMessageType> 
    <amprice:AMPrices xmlns:amprice="http://www/am.com/am/dto/price"> 
     <Price> 
      <Currency>GBP</Currency> 
      <Country>LU</Country> 
      <BusinessLine>AMSL</BusinessLine> 
     </Price> 
    </amprice:AMPrices> 
</AMUpdate> 

回答

2

請嘗試以下的XPath,

/AMUpdate/amprice:AMPrices/Price/* 

您XML關閉標籤丟失。請找到更新的XML,

<AMUpdate> 
 
    <AMMessageType>AMPRICES</AMMessageType> 
 
    <amprice:AMPrices xmlns:amprice="http://www/am.com/am/dto/price"> 
 
    <Price> 
 
     <Currency>GBP</Currency> 
 
     <Country>LU</Country> 
 
     <BusinessLine>AMSL</BusinessLine> 
 
    </Price> 
 
    </amprice:AMPrices> 
 
</AMUpdate>

您可以嘗試測試的XPath返回here

+0

沒有:http://www.xpathtester.com/colored/134b06bf66abb25bf4f2689a248baeae – methuselah

+0

您XML有缺少關閉標籤。我用正確的XML和鏈接更新了答案,您可以在其中測試我提供的XPath。它爲我工作。 –