Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
sonalijagtap
Contributor III
Contributor III

XML Input

Hi Team,

 

below is my sample xml data.

<test>
<node id="1" />
<node id="2" />
<node id="3" />
<node id="4" />
<node id="5" />
<node id="1" />
</test>

My loop is on "/test"

in the xpath query for id, I am writing "node/@id", but it is giving me first entry only where id=1.

but i want all the id's, also I don't want to change the loop because other fields are related on that loop only. what should be the xpath query to get all the id's?

 

Thank You,

Sonali Jagtap

Labels (3)
6 Replies
fdenis
Master
Master

try to getout the full node then loop on node.
good luck
iamabhishek
Creator III
Creator III

Try this way -

 

0683p000009LzIJ.jpg

 

sonalijagtap
Contributor III
Contributor III
Author

Hi,

I will not work in my case.

My loop will be on /test only. because there are other nodes as well along with "/test/node".

So my loop has to be on "/test"

I need to change the xpath query for id to get all the id's present in "node".

 

Thank You,

Sonali Jagtap

fdenis
Master
Master

when you are converting XML to Row the loop define the number of row.
if you are on test --> x ¨row
if you are on node --> x*y row
Regards
sonalijagtap
Contributor III
Contributor III
Author

Hi, Please find my sample file,

 

<Response storeId="319">
<ProductTable>
<ProductInfo id="1001" name="TEST" />
<ProductInfo id="1003" name="TEST1" />
<ProductInfo id="1007" name="TEST2" />
</ProductTable>
<DayPartitioning>
<Segment id="1" begTime="0800" endTime="0814" dayOffset="0"/>
<Segment id="2" begTime="0815" endTime="0829" dayOffset="0"/>
<Segment id="3" begTime="0830" endTime="0844" dayOffset="0"/>
<Segment id="4" begTime="0900" endTime="0914" dayOffset="0"/>
<Segment id="5" begTime="0915" endTime="0929" dayOffset="0"/>
<Segment id="6" begTime="0945" endTime="0959" dayOffset="0"/>
<Segment id="7" begTime="1000" endTime="1014" dayOffset="0"/>
<Segment id="8" begTime="1015" endTime="1029" dayOffset="0"/>
<Segment id="9" begTime="1030" endTime="1044" dayOffset="0"/>
</DayPartitioning>
</Response>

 

I want all the data for StoreID=319 Please help me with the correct XPATH Query & Loop. Thank You, Sonali Jagtap

fdenis
Master
Master

xml is structured data as tree.
your stored id give you 2 dataset
one for Product
one for DayPartitioning
so you have to read your file 2 time one for each
then match on stored Id

to avoid 2 time reading you can split xml 2 header nodes as documents.