Recommendation for 'consuming' a Message?
Assuming a message like this example:
req_payload_string = <<XML
<ns1:echoString xmlns:ns1="http://ruby.wsf.wso2.net/samples">
<text>Hello World!</text>
</ns1:echoString>
XML
What would you recommend using on the provider side to get to the <text> element?Using REXML like the following?
doc = REXML::Document.new req_payload_string
doc.elements.each("*/text") { |element| puts element.text }Or is there a better way to access the field?
Thanks,
Thierry
- Login or register to post comments
- Printer friendly version
- 206 reads










Re: Recommendation for 'consuming' a Message?
Hi Thierry,
First of all, the answer for your question mainly depend on the context of your application. So it would be difficult to give an specific answer(or a code) for that.
Once the provider receives the payload, you can follow any xml parsing technique you like to retrieve information. So YES, your code seems okay for the given XML. But if you are interested in only the <text> tag, you don't need to use a loop to get it, isnt it?
Of course, you can use REXML as your XML parser. You may refer REXML documentation/samples for further information.
regards,
Janapriya