Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Problem with XPath query (pick value based on attribute in multi element)

Hi All;

I'm facing problem with XPath query in tFileInputXML, when I'm using query with element number defined:

/Tracks/SegmentTrack[1]/Value

 

It is working but when I use conditional:

/Tracks/SegmentTrack[Value/@type='magnetic']/Value

 

It returns null, I've tried with \" instead of ', but still same result. I've tested query online and it is working correctly, site used:

https://www.freeformatter.com/xpath-tester.html#ad-output

 

Am I doing something wrong or this kind of queries are not supported?

If not supported, do you have any suggestion without heavy string parsing?

 

 

 

All suggestions really appreciated.

Thank you very much

BR/Artur

Labels (3)
1 Solution

Accepted Solutions
manodwhb
Champion II
Champion II

@GnuS,check the txmlinput settings,since i was able to get wth below0683p000009LxaP.png0683p000009LwxO.png.

 

View solution in original post

6 Replies
manodwhb
Champion II
Champion II

@GnuS,try with below one should reslove.

 

"/Tracks/SegmentTrack[Value/@type='magnetic']"

Anonymous
Not applicable
Author

Hi;

@manodwhb It is same, NULL, besides the fact that I need Value not whole element.

 

BR/Artur

manodwhb
Champion II
Champion II

@GnuS,check the txmlinput settings,since i was able to get wth below0683p000009LxaP.png0683p000009LwxO.png.

 

Anonymous
Not applicable
Author

Hi;

I have to dig a bit more but you are correct it is working (real XML is bigger and cannot share it).

 

Thank you very much for your time and help.

 

BR/Artur

Anonymous
Not applicable
Author

Hi All;

I hope it will be helpful for somebody, I've found the reason of my problem, XML which I'm parsing is actually double loop (example was a cut), my loop is on LEVEL_A because I want to have records per it, and searching on SegmentTrack will not work, it will simply pickup first one, that's it and will not iterate through others to find needed record. What is confusing is that online parsers does work on second loop searches. Below XML with representation of my XML.

 

 <LEVEL_As>

  <LEVEL_A seq=1>

 <Tracks>
   <SegmentTrack>
   <Value type="true" unit="deg">341</Value>
   </SegmentTrack>
   <SegmentTrack>
   <Value type="magnetic" unit="deg">338</Value>
   </SegmentTrack>
   </Tracks>   

  </LEVEL_A>

<Tracks>
   <SegmentTrack>
   <Value type="true" unit="deg">341</Value>
   </SegmentTrack>
   <SegmentTrack>
   <Value type="magnetic" unit="deg">338</Value>
   </SegmentTrack>
   </Tracks>   

  <LEVEL_A seq=2>

  </LEVEL_A>

...

  <LEVEL_A seq=N>

<Tracks>
   <SegmentTrack>
   <Value type="true" unit="deg">341</Value>
   </SegmentTrack>
   <SegmentTrack>
   <Value type="magnetic" unit="deg">338</Value>
   </SegmentTrack>
   </Tracks>   

  </LEVEL_A>

 </LEVEL_As>

Ashwin_Ramdass_007
Contributor
Contributor

Hello Sir,

I am new to XML and I can't actually, I also got the same error(Xpath query lost).

I am attaching the XML file in this message.