
Questions: 23,729 //
Answers: 52,300 //
Contributing Members: 17,997
Hi, I am doing simple Mule flow. Reading xml file from file connector and using the Splitter I am dividing the message and writing into different path. Mule Flow: <flow name="write-xml-file-to-pathFlow1">
<file:inbound-endpoint path="./src/main/resources/in" connector-ref="File"
responseTimeout="10000" doc:name="File" pollingFrequency="5000"
moveToDirectory="./src/main/resources/out">
<file:filename-regex-filter pattern="product.xml" caseSensitive="true"/>
</file:inbound-endpoint>
<splitter expression="#[xpath3('//product')]" doc:name="Splitter"/>
<mulexml:dom-to-xml-transformer doc:name="DOM to XML"/>
<file:outbound-endpoint path="./src/main/resources/out" connector-ref="File1"
responseTimeout="10000" doc:name="File"/>
<logger message="#[payload]" level="INFO" doc:name="Logger"/>
</flow>
And the xml file is:
<Products>
<product>
<pid>m1</pid>
<pmodel>mbm1</pmodel>
<pname>mobile</pname>
<price>6000.0</price>
<stock>20</stock>
</product>
<product>
<pid>m2</pid>
<pmodel>mbm2</pmodel>
<pname>mobile</pname>
<price>8000.0</price>
<stock>10</stock>
</product>
Jun 06, 2018 at 09:56 PM, brad_c answered with:
Hi @yaligararun,
The xpath3
function by default returns a string representation of the selected data, not a collection (hence your error).
What you actually want is the set of matching nodes so that you can iterate over them - to get this you need to change your expression from #[xpath3('//product')]
to #[xpath3('//product',payload,'NODESET')]
.
See the documentation here for more information.
Jun 07, 2018 at 07:06 AM, yaligararun answered with:
Hey @brad_c
Thanks a lot. It worked. I was thinking that 'NODESET' can be used only when we have IDs for the tags. It worked. Thanks again
Arun
How to extract the UUID from below XML 0 Answers
Xpath to store node value from xml 2 Answers
How to use xpath commands inside of Dataweave? 0 Answers
How to read a soap XML response data in Mule Variable. 3 Answers
How to use xpath3 in dataweave 1 Answer