Monday, September 21, 2015

[WSO2 ESB] How to read a value from xml file stored in a registry

You can do like this. Here we have below test.xml file stored in gov:/test.xml

<root>
<book>A Song of Ice and Fire</book>
<author>George R. R. Martin</author>
</root>
view raw books.xml hosted with ❤ by GitHub
Your synapse configuration should be like this. Here we use xapth to read the XML.

<property name="xmlFile" expression="get-property('registry','gov:/test.xml')" scope="default" type="OM"></property>
<log level="custom">
<property name="Book_Name" expression="$ctx:xmlFile//book"></property>
</log>
view raw reg_xpath.xml hosted with ❤ by GitHub
Your output log will look like this.

[2015-09-21 16:01:28,750]  INFO - LogMediator Book_Name = A Song of Ice and Fire 

Please comment below if you have any questions.

Related:
How to read a file from registry
How to read a registry property

No comments:

Post a Comment