XML Path transform to table

I everyone, I’m super new to knime and I am having troubles to convert my XML file into a table, through the XPath node, for further manipulation where i want to group average number of cases by country and month.

This is the xml file location/API that i used in the get request node: https://opendata.ecdc.europa.eu/covid19/nationalcasedeath_eueea_daily_ei/xml/

I think i might be definiting my xpath value query wrongly.

Can someone help please?

Hi @AdrianaFerro and welcome to the community!

Yes, your xpaths are wrong, and they need to be something like the following:

dateRep /records/record/dateRep String(Multiple Rows)
day /records/record/day Integer(Multiple Rows)
month /records/record/month Integer(Multiple Rows)
year /records/record/year Integer(Multiple Rows)
cases /records/record/cases Integer(Multiple Rows)
deaths /records/record/deaths Integer(Multiple Rows)
countriesAndTerritories /records/record/countriesAndTerritories String(Multiple Rows)
geoId /records/record/geoId String(Multiple Rows)
countryterritoryCode /records/record/countryterritoryCode String(Multiple Rows)
popData2020 /records/record/popData2020 Integer(Multiple Rows)
continentExp /records/record/continentExp String(Multiple Rows)

To populate the xpaths, you can highlight the element name in the preview panel and the “Selected XPath” will be displayed in the upper panel.

To quickly add an xpath, mark the item in the preview window, check that the “Selected XPath” is displayed in the upper panel, click “Add XPath”, set the return type, and the required “Single/Multiple/Collection” option, and click OK

Hope that helps get you started.

4 Likes

Hi takbb, thank you for the warm welcoming and for the help. It is solved :slight_smile:

3 Likes

Hi @AdrianaFerro , I’m glad you got it working.

If you have python3 installed in your KNIME environment, you may be interested in a component I have been working on. Attached is a workflow that demonstrates it in action with the url you gave earlier. Basically as that is very basic row-based xml, it can turn it directly into a table with no configuration. I’m still in the process of testing it under different situations, but it may be of interest if you are doing much work with xml, and I’d welcome any feedback, and of course if you spot any bugs!

image

KNIME_easy_read_xml.knwf (52.8 KB)

The component can be downloaded directly from

3 Likes

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