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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

XPath - how to use position() in XMLInput

Hello folks,
i have come across this file that has no identifier for the <b>Item</b>:
<Items>
<Item>
<Detail1>A</Detail1>
<Detail3>B</Detail2>
<Detail4>B</Detail4>
...
</Item>
<Item>
<Detail2>B</Detail2>
<Detail4>B</Detail4>
...
</Item>
...
</Items>

i would like to get the output of this file normalised to:
Item   |Detail1   |Detail2     |Detail3     |Detail4
1 |A | |B |B

where the value of item would be returned by the XPath expression position()
But i am failing to understand how the expression should be entered in the tFileInputXML
this is a similar question to:
https://community.talend.com/t5/Design-and-Development/XML-record-count/td-p/74328

and i would very much appreciate assistance with this.
regards
Labels (3)
1 Reply
Anonymous
Not applicable
Author

This shows an XPath that returns the sequence of the parent node.
http://blogs.msdn.com/b/asanto/archive/2004/09/08/226663.aspx
count(parent::*/preceding-sibling::*) + 1

However when run in 'Refresh Preview' or in a job the column is empty.
When the job is configured with 'Get Nodes' enabled on the tFileInputXML then the results show that the sequence is being calculated.
e.g. from a different dataset:
.-------------------+----------------------------------+--------.
| tLogRow_1 |
|=------------------+----------------------------------+-------=|
|key |value |entityid|
|=------------------+----------------------------------+-------=|
|key="jurisdiction" |value="GB" |1.0 |
|key="domicile" |value="UK" |1.0 |
How can the column I call 'entityid', computed from the earlier 'count...' XPath be accessed?
The first two columns of output show the full node value of their attribute, so could potentially be parsed.