XPath in XMLMap

Five Stars aoh
Five Stars

XPath in XMLMap

Hello,
I'm trying to get an XPath-Query working in a XML-Map. But I got some problems with it.
The XML is from a webservice an I need the XML as it is, just with some additional data. It is an invoice with several lines. I need to add the total.
An option would be an tExtractXMLField with tAggregateRow, then put the value on the global map an read the xml-document an the total after FlowToIterate.
Is there an easier option?

The best solution would be to get the total with an XPath-Query in the XML-Map.

A simlyfied example is this one:
XML-Structure:
<invoice>
<line>
<nr>1</nr>
<amount>100</amount>
</line>
<line>
<nr>2</nr>
<amount>100</amount>
</line>
</invoice>

When I read the XML from a file and put the XPath in tFileInputXML it works.
When I read the XML as a node an put the XPath in an XMLMap (what I want for the webservice) it stops with an error (method not defined).
Is there a way to get XPath working in tXMLMap?
Employee

Re: XPath in XMLMap

Hi aoh,
Please refer to my attachment solution.png.
First you can use tConvertType component convert you output String type to what you want to (like Integer,Double and so on ).
And then pass the value to another tXMLMap component.

Cloud Free Trial

Try Talend Cloud free for 30 days.

Tutorial

Introduction to Talend Open Studio for Data Integration.

Definitive Guide to Data Integration

Practical steps to developing your data integration strategy.

Definitive Guide to Data Quality

Create systems and workflow to manage clean data ingestion and data transformation.