骡子中的xpath3问题

时间:2017-09-12 13:52:53

标签: xpath mule mule-component

这是我的传入有效载荷。

<?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 个答案:

答案 0 :(得分:1)

请使用End Using获取errorCode。我使用' Using FileObject As New FileStream(fileName, FileMode.Create, FileAccess.Write, FileShare.None) ' Using StreamWriterObj As New StreamWriter(FileObject) Using StreamWriterObj As New StreamWriter(path:=fileName, append:=False) 来定义命名空间通配符。如果要使用命名空间,可以将其定义为

#[xpath3('/detail/*:SiperianRequestFault/*:errorCode')]

然后表达式就像*:

希望这有帮助。