XML File reading

Hi,

I am trying to read a XML file but the table remains empty.
What I would like to be able to do is to fill in a table with information contained in nodes.Inspection.xml (56.1 KB)

Thanks

Hi @vincentparez and welcome to KNIME Community,

Read the file with the XML Reader and then extract what you need with the XPath node.

:blush:

1 Like

Hi @armingrudd.

As you can see I am a newbie. I found some workflows examples that were using XML Reader and XPath node. And I tried to reproduce it with the file I uploaded, but without any success.

Provide me with your desired output table. What do you want to extract from the XML file?

I would like to have in one table, data in relation with (line 479 in xml file) and in another table the detailed information in relation with and (line 499)

Hi @vincentparez,

when you drag & drop your XML into Knime it automatically creates an XML Reader node which links to your file. That reads the whole XML. However, if you’d like to load only a certain child like “Datenkollektive” you can already do that by defining the absolute XPath: /Identifikation/Datenkollektive

As far as I understood you’d like to that a table containing “Rohrleitung” (row 479) in conjunction with it’s children “Inspektionsdaten” (row 499). Both elements are present multiple times.

So you:

  1. read the whole XML file
  2. Use XPath to separate each “InspizierteAbwassertechnischeAnlage” who’s children are “Rohrleitung” and “Inspektionsdaten” into single rows
  3. Use XPath to extract the desired information

In order to obtain the XPaths you might double click on the desired note. Please node that the XML preview is only 1.000 rows long and sometimes the name space “dns:” has to been prefixed to the XML elements in your XPath. Another trick might be to use Sublime or another editor through which you can copy the current nodes XPath location.

Though, by looking at the XML I think you’d like to have a table containing almost all information and not just a few selected ones. Correct?

Edit: Referring in my last sentence to Inspektionsdaten > RZustand with variating children like Charakterisierung1, Charakterisierung2 etc.

Edit 2: Got something you might find beautiful :wink:

https://hub.knime.com/mw/spaces/Public/latest/Knime%20Forum%20Support/Read%20XML,%20dynamically%20extract%20data%20and%20combine%20everything

Kind regards
Mike

6 Likes

Thanks a lot Mike. It is definitively what I was trying to do, but didn’t know when and how to use dns and namespace

1 Like

Hi @vincentparez,

great to hear you like it. Hope it’s well documented enough so you can comprehend what’s actually done. Would appreciate if you add a like to my solution.

Happy Kniming
Mike

2 Likes

Perfectly clear.
Thanks again

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