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.
2 REPLIES
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