Jump to content
We have recently updated our Privacy Statement, available here ×

Xpath for each iteration comparing two xml nodes


Recommended Posts

Hi All,

I have a scenario to compare two xml and map the thrid xml contents based on some matching criteria, but it doesn't work exactly the way we are looking for. It takes for matching condition and default always

from the below xml, i need to match the state from source xml with comparing xml, if it matches map description contents to links node of target xml. If state doesn't match with source data then consider the NATIONAL state and map the links

Source Data xml

 

 

 

CA

 

 

comparing xml

 

 

 

 

CA

some links

 

 

NY

some links

 

 

NAATIONAL

some links

 

 

 

 

Target xml (condition to match state id else get the national link)

 

 

matching links from comparing xml

 

 

 

xpath condition

for each (products/product/states/state)

when (id = root/customer/address/state)

map links = ./description

when (id = "NATIONAL")

map links = ./description

 

i tried lot of options, but couldn't able to achieve the correct logic, able getting both state id and national records.

 

Please help with me with some ideas to get only matching records using xpath

Thanks

Raam

Link to comment
Share on other sites

What is not working for you. You need two forEach mappings, what you have above looks right, not sure if you have mapping issues.

Alternatively, you could use count to check when(count(root/customer/address[state=./id])>0) then ./description when (./id='NATIONAL') then ./description.

I am not clear on your XML structures to give more detailed answer

Link to comment
Share on other sites

×
×
  • Create New...