2

I'm using the 'tRest' component to perform a HTTP Post. When that request succeeds, I receive information in XML format. How can I access that information in the next component? My next step is to convert that information in a CSV format. And if I want to save the information I get from the HTTP Post into a XML file, how can I do that?

Thanks.

user2144555
  • 1,315
  • 11
  • 34
  • 55

1 Answers1

3

tRest components allow you to make http calls to REST services (both GET and POST are supported) and retrieve the responses in a String field called 'body'. Then you can parse these XML responses using the tExtractXMLComponent which, as the name states, extracts one or more fields from the XML according to XQuery paths. It outputs to standard structured rows.

This example job calls a public REST service and output to console both the parsed response and the raw XML body. Talend job using tRest

And here's the above example properties for tExtractXMLField. Notice how each output column is mapped to a field of the response throught the use of XPath queries.

enter image description here

Gabriele B
  • 2,665
  • 1
  • 25
  • 40
  • Have a look on the second screenshot; in the third parameter selection you must select which field of the incoming connection ('Body' in this case) contains the response. Then, you feed with XPath/XQuery expressions to retrieve the nested fields. – Gabriele B Dec 02 '13 at 14:55
  • Yes, I saw the "Body" variable in you screen, but it didn't appear in my XML Field Combo Box. After several attempts (with a XMLinput instead of the tRest component) it started to appear... Anyway, thanks. Now it is working! – user2144555 Dec 02 '13 at 15:25