Extract Data from XML using tExtractXMLField

One Star

Extract Data from XML using tExtractXMLField

I need to Fetch the value of data from XML having multiple same elements :-
<Phones>
<ContactPhone>
<number>Example string value.</number>
<useType readonly="true">Home</useType>
</ContactPhone>
<ContactPhone>
<number>Example string value.</number>
<useType readonly="true">Work</useType>
</ContactPhone>
<ContactPhone>
<number>Example string value.</number>
<useType readonly="true">Pager</useType>
</ContactPhone>
<ContactPhone>
<number>Example string value.</number>
<useType readonly="true">Mobile</useType>
</ContactPhone>
<ContactPhone>
<number>Example string value.</number>
<useType readonly="true">Fax</useType>
</ContactPhone>

If UseType is Home the the Number in that ContactPhone is Extracted, else if UseType is Work the that Number should be extracted. How can i achive this , also the data is to fetched from API, SO there might be possibility the complete tags /phone number might not appear.
Moderator

Re: Extract Data from XML using tExtractXMLField

Hi,
You can extract all data from XML string with tExtractXMLField, and then filter the rows with tFilterRow or tMap component.
Best regards
Sabrina
--
Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.
Seventeen Stars

Re: Extract Data from XML using tExtractXMLField

hi all,
as far as I know, tExtractXMLField use dom4j parser.
by that way you're able to use some filter in yout Xpath expression but could become 'touchy'.

regards
laurent

Calling Talend Open Studio Users

The first 100 community members completing the Open Studio survey win a $10 gift voucher.

Start the survey

2019 GARNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

What’s New for Talend Summer ’19

Watch the recorded webinar!

Watch Now

Best Practices for Using Context Variables with Talend – Part 4

Pick up some tips and tricks with Context Variables

Blog

How Media Organizations Achieved Success with Data Integration

Learn how media organizations have achieved success with Data Integration

Read

Agile Data lakes & Analytics

Accelerate your data lake projects with an agile approach

Watch