简体   繁体   English

如何在WSO2 esb中使用xpath来获取xml子节点

[英]How to fetch xml child node using xpath in WSO2 esb

I have a xml payload as below, 我有一个xml负载,如下所示,

<ret:msgData xmlns:ret="http://example.com/ret" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <users>
        <fbuser>user1</fbuser>
        <fbuser>user2</fbuser>
        <googleuser>user2</googleuser>
    </users>
</ret:msgData>

From this payload I need all the fbuser nodes. 从这个有效载荷中,我需要所有fbuser节点。 For this I used below xpath in property mediator in esb. 为此,我在esb的属性中介器中的xpath下使用了此功能。 But it gives me values and not nodes. 但这给了我价值观而不是节点。

 <property xmlns:ret="http://example.com/ret"
           name="fbuser"
           expression="//ret:msgData/users/fbuser"
           scope="default"
           type="STRING"/>
 <log level="custom" separator=",">
    <property name="fbuser" expression="get-property('fbuser')"/>
 </log>

The output that gets printed is user1user2 Instead I am looking for output as below. 输出的输出是user1user2相反,我正在寻找如下输出。

<fbuser>user1</fbuser>
<fbuser>user2</fbuser>

When I test the xpath in http://www.freeformatter.com/xpath-tester.html The same code gives me proper output. 当我在http://www.freeformatter.com/xpath-tester.html中测试xpath时,相同的代码为我提供了正确的输出。

Please suggest. 请提出建议。

坦率地说,使用XSLT可以更好地解决此问题,该XSLT旨在将XML从一个应用程序提取/转换为另一个应用程序。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM