Extract XML field data on a condition

Seven Stars

Extract XML field data on a condition

 

Hi,

 

I have source data like below in xml file.

 

 <OrganizationHierarchy Level="OperatingCompany">NMBR</OrganizationHierarchy>
<OrganizationHierarchy Level="Division">TBC</OrganizationHierarchy>
<OrganizationHierarchy Level="Concept">TBC</OrganizationHierarchy>

 

I am pulling data using tXMLMap. PFB screenshots.

 

Output Field1 - i have to pull "organization hierarchy" field based on Level=Division 

Output Field2 - i have to pull "organization hierarchy" field based on Level =OperatingCompany 

Output Field3 - i have to pull "organization hierarchy" field based on Level =Concept

 

how to achieve this in tXMLMap component.

 

For output field1 i have created like this. is it correct. Hope something wrong. Please assist me.

 

[row2.Filename:/POSLog/Transaction/OrganizationHierarchy/@Level].equals("Division") ?
[row2.Filename:/POSLog/Transaction/OrganizationHierarchy] : null

 

 

Thanks,
Sid
Mark as solution if this resolved your issue
Community Manager

Re: Extract XML field data on a condition

It looks like you are going in the right direction. But you might want to look at tMap/tXMLMap variables. This tutorial isn't using xml, but demonstrates a way of handling your issue (https://www.rilhia.com/tutorials/dynamic-column-order)

Seven Stars

Re: Extract XML field data on a condition

I didn't understand completely. in the blog you are using tmap instaed of txmlMap.

so solution will become little differnt. What i am looking here is sysntax for pulling data withrespect to different conditions in tXMLmap.

Output Field1 - i have to pull "organization hierarchy" field based on Level=Division
Output Field2 - i have to pull "organization hierarchy" field based on Level =OperatingCompany
Output Field3 - i have to pull "organization hierarchy" field based on Level =Concept

something like below :

[row2.Filename:/POSLog/Transaction/OrganizationHierarchy/@Level].equals("Division") ?
[row2.Filename:/POSLog/Transaction/OrganizationHierarchy] : null
Thanks,
Sid
Mark as solution if this resolved your issue
Community Manager

Re: Extract XML field data on a condition

Yes, the solution will be a little different. The tutorial was given to give an idea of what may be required.

 

Your example code should just about solve your issue I believe....

 

[row2.Filename:/POSLog/Transaction/OrganizationHierarchy/@Level].equals("Division") ?
[row2.Filename:/POSLog/Transaction/OrganizationHierarchy] : null

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 1

Learn how to do cool things with Context Variables

Blog

Migrate Data from one Database to another with one Job using the Dynamic Schema

Find out how to migrate from one database to another using the Dynamic schema

Blog

Best Practices for Using Context Variables with Talend – Part 4

Pick up some tips and tricks with Context Variables

Blog