I'm trying to use xpath in a Mule flow to select the attribute 'value' under element Host based on the current value of element Stage (which will be in a Mule variable)
Here's the XML resource file feedHosts.xml
<?xml version="1.0"?>
<FeedHosts xmlns:bar="http://www.bar.org" xmlns:foo="http://www.foo.org/">
<Host value="host1.com">
<Stage>qa</Stage>
</Host>
<Host value="host2.com">
<Stage>dev</Stage>
</Host>
<Host value="host3.com">
<Stage>live</Stage>
</Host>
</FeedHosts>
I've tried a few things like
<set-payload value="#[groovy: getClass().getResourceAsStream('/feedHosts.xml')]" doc:name="Set Payload to feedHosts.xml"/>
<byte-array-to-string-transformer doc:name="Byte Array to String"/>
<mulexml:xpath-extractor-transformer name="whatever" expression="/FeedHosts/Host[Stage='#[flowVars.stage]']" resultType="NODE"/>
<logger message="#[payload]" level="INFO" doc:name="Logger"/>
This does load feedHosts.xml into the payload but the xpath-extractor-transformer itself returns a null payload. Obviously it won't return the value attribute I want.
Any help appreciated.
<logger message="#[flowVars.stage]" level="INFO" doc:name="Logger"/>
output? - Marcus Rickert