使用xpath检索wso2esb中的特定节点

时间:2014-02-26 05:50:43

标签: xml xpath wso2esb

我正在使用wso2esb 4.7.0,以下是我的消息:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<request xmlns="http://ws.apache.org/ns/synapse">
<user>sps</user>
<pwd>sps123</pwd>
</request>
</soapenv:Body>
</soapenv:Envelope>

我想检索用户信息,因为我已经这样做了

/soapenv:Envelope/soapenv:Body/request/user

但我没有得到任何东西。如果我尝试了

/soapenv:Envelope/soapenv:Body

然后我得到了

<soapenv:Body xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Envelope>
<soapenv:Body>
<request xmlns="http://ws.apache.org/ns/synapse">
<user>sps</user>
<pwd>sps123</pwd>
</request>
</soapenv:Body>
</soapenv:Envelope>
</soapenv:Body>

我应该如何获取用户信息?

1 个答案:

答案 0 :(得分:0)

data(//*:Envelope/*:Body/*:request/*:user)

输出

sps

/*:Envelope/*:Body/*:request/*:user

输出

<user xmlns="http://ws.apache.org/ns/synapse"
  xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">sps</user>