XPath Missing Value questions

Hi, I am still on Knime 3.2.1
I am using Xpath to process XML file.
in the file, I put three xpath , first one is first level , have three path query in there, two of them are regular, third one is node cell, then second xpath read from the third node cell.
The issue is that the third one is not always in the XML , some records has it , some records doesn’t have.
So the value is moved up and matched with wrong first two regular path query.
What setting I missed to make it work and match?


what I want to say is:
In one Xpath, I put in three Xpath query.
for example

I noticed that the first two always in the XML. But for some records, the third one is not in there. So when Xpath read the third one, it will not find the element, and what happened is, when I finally write the xpath result to a table, the producer column has data , but it is not matching the title and director. it used next value it can find for producer.
What I can do to fix this issue?

Thanks a lot.

Hi @fanrf and welcome back to the KNIME forum,

Try catching the parent instead of the element which is missing in some rows and then extract the inner values. That would solve the issue.

An example:


The tag “second_level” is missing in the second “first_level” tag. Instead of querying “second_level” as a node, catch “first_level” elements and then in the second XPath node, extract the “c” and “d” values.


Thanks a lot.
I should have updated my post.
I finally fixed the issue. the way I did is:
use one xpath to pull all I need first, then for the ones have multiple values, I use node cell as output, then split the result from the xpath to 5 xpath , each of them take care of one of the elements. but they all have two elements are same , for example , the title.
Then group by at the end, then do 4 joiners to join the result together, then write to a table. In this way, it works just fine now.


1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.