2017-09-12 47 views
0

這是我的傳入負載。mule中的xpath3問題

<?xml version="1.0" encoding="UTF-8"?> 
    <detail><ns1:SiperianRequestFault xmlns:ns1="urn:siperian.api"> 
    <ns1:requestName>SearchQuery</ns1:requestName> 
    <ns1:errorCode>SIP-18018</ns1:errorCode> 
    <ns1:errorMessage>SIP-18018: Request not recognized by the user profile providers. 
Review the server log for more details.</ns1:errorMessage> 
</ns1:SiperianRequestFault></detail> 

當我查詢

xpath3('//detail')

這裏是輸出

SearchQuerySIP-18018SIP-18018: Request not recognized by the user profile providers.Review the server log for more details. 

但我要的是提取errorCode, errorMessage

回答

1

請使用#[xpath3('/detail/*:SiperianRequestFault/*:errorCode')]來得到errorCode。我已經使用*:來定義名稱空間通配符。如果你想使用命名空間,你可以將它定義爲

<mulexml:namespace-manager includeConfigNamespaces="true"> 
    <mulexml:namespace prefix="ns1" uri="urn:siperian.api" /> 
</mulexml:namespace-manager> 

則表達式會像#[xpath3('/detail/ns1:SiperianRequestFault/ns1:errorCode')]

希望這有助於。

+0

非常感謝兄弟! – Dhanjeet