List in list data source

I use an XML file as data source. I created a smaller file with a similar-looking structure for this example:

cd_catalog_2.xml (745 Bytes)
image

I can load this file with a XML reader just fine. As you can see, there are multiple price tags per item. What I would like to achieve is a table where a row represents a price entry.
In this case I would have something like:

CD.id PRICE.country Price.Currency
1 fr eur
1 de eur
1 us usd
2 ... ...

I have tried using the XPath node to extract only prices: it works, but I lose the CD id, and if I add the CD.Id to the output, only one price is returned.

I was not able to find how to handle this situation, since most examples are based on “flat” data like CSV or database rows.

How would you do, and where to start?

I am a new Knime user, I might have missed something obvious.

Thank you

Hi @PaulCombal,
welcome to the KNIME Forum, I am sure I can help you with this, I think all you need is the correct xpath setttings.
To help you find them could you be so kind and share a small sample of your input file with us? Maybe with the first two items?

best,
Gabriel

Thank you @gab1one , I believe the input file I included in my first message (just above the picture) is enough to get the general idea. Do you need anything else?

Hi @PaulCombal,

I wanted to avoid typing it up by hand but in the end I just quickly did that. Anyway, take a look at this workflow, that should solve your problem:

I had to use two xpath nodes, in the first I split up the input file into cells one for each CD object, I then did the data extraction in the second xpath node.

best,
Gabriel

3 Likes

That’s it! I couldn’t have guessed it myslef. Thank you very much for your help!

I am happy I could help you, please feel free to ask more questions anytime you need help and make sure to check out KNIME Learning | KNIME

best,
gabriel

1 Like

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