Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik GA: Multivariate Time Series in Qlik Predict: Get Details
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

File xml -- Get Loop Index for the xpath

We are using filexml to parse a xml file.

 

We have a requirement to find the loop index, is there any xpath expression to populate the counter

Our file looks like

 

<REPORT>

      <HEADER>

                 <KEY>

      <ITEM>

                 <F1>value1<F1/>

                <F2>value2<F2/>

     <ITEM/>

     <ITEM>

              <F1>value3<F1/>

              <F2>value4<F2/>

     <ITEM/>

    <HEADER/>

    <REPORT/>

 

For the above example, my output should be

ITEM value1 value2 1(loop index counter)

ITEM value3 value4 2(loop index counter)

 

We need to know the loop index for the <ITEM/> when we are parsing in FileXML? Are there any valid xpath expression i can use to determine the counter.

 

Thanks

Srini

Labels (2)
1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

This helps count(preceding-sibling::*)+1 in getting the loop index of an XML

View solution in original post

3 Replies
Anonymous
Not applicable
Author

Hello,

Do you want to output a xml file including multiple loop elements?

Could you please elaborate your case with an example with input and expected output values?

Best regards

Sabrina

Anonymous
Not applicable
Author

Hi,

We are parsing the xml files by using file xml option

My Input is

<diagnosis>
<code="I10">CODE1</code>
<displayName>CODE1 DESCRIPTION</displayName>
</diagnosis>
<diagnosis>
<code type="I10">CODE2</code>
<displayName>CODE2 DESCRIPTION</displayName>
</diagnosis>

 

Output should be

CODE1
CODE1 DESCRIPTION
1

CODE2
CODE2 DESCRIPTION
2

 

For every loop of <diagnosis> we need get the counter.

What functions we can use in file xml to get the counter for the nodes?

 

Thanks

Srini

Anonymous
Not applicable
Author

This helps count(preceding-sibling::*)+1 in getting the loop index of an XML