Support Questions
Find answers, ask questions, and share your expertise

How to include parent fields with the output record fields while parsing XML data in NiFi?

Explorer

Hello All,

I am new in NiFI. I have below nested xml file and I need to keep the parents node <track id> with its multiple record <switch id> in a same flow file. I already able to separate them but not able to keep them in a same flow file attributes record.

 

So, it will be highly appreciated if anyone please help me how can I Include parent fields <track id> into the output record <switch> and what will be my flow file?

 

XML Looks like:

 

track_xml.JPG

 

My flow file looks like:track_switch.JPG

My expected output:

flow-file attributes should be:

track_id:

1

track_name:

TR_3B_ASW_ITW

switch_id:

2

track_continue_course:

Straight

pos:

554.05

So that I can write table into database using PutSQL as below:

 

track_id

track_name

swithc_id

track_continue_course

pos

1

TR_3B_ASW_ITW

2

Straight

554.05

1

TR_3B_ASW_ITW

3

Straight

2654.64

1

TR_3B_ASW_ITW

4

Straight

2767.56

 

0 REPLIES 0