XPath does not return the proper content

Hi,

I’m trying to retrieve the content of cells in a HTML table. The page is the following:

https://echa.europa.eu/information-on-chemicals/cl-inventory-database/-/discli/details/25621

I’m trying to retrieve the content of the cells under “Pictograms, Signal Word Code(s)” in the orange table using XPath. My XPath query looks like this:

//*/table[@class=“CLPtable taglib-search-iterator”]/descendant::td[contains(@class, ‘centerText cli-vertical-align-center’) and contains(text(), ‘GHS’)]

This query works as expected in the Elements Console in Chrome (proper content highlighted, but when I retrieve the page with the Palladian HTTPRetrieve / HTML Parser, followed by the XPath node, I get an empty Collection cell.

Other, similarly formatted queries retrieve the right content into a Collection cell.

Thank for your help
Serge

Hi,

Can you post an example workflow?

– Philipp

“dns:”
/dns:html/dns:body/div[4]/div/div/div/div/div/div[2]/div/div[2]/div[2]/div/table[2]/tbody/tr[1]/td[1]

Chrome add
image

Sure !
XPath_Example.knwf (254.1 KB)

Thanks, but the issue is, I need to match all cells under the Pictograms,… column, and depending on the page I call, this may be one cell, or 10, or whatever, so the query must be generic enough.

The approach is wrong, there are shortcomings.


@umutcankurt Thanks, but again, this is not the information I need. Both first queries (Test3 and Title) return the right information (as seen in your screenshot above). The query that does not return the proper information is the one called GHS. In Chrome, it identifies the proper content but in KNIME it returns an empty collection.

Xpath
/dns:html/dns:body/dns:div/dns:div/dns:div/dns:div/dns:div/dns:div[2]/dns:div[2]/dns:div/dns:div[2]/dns:div[2]/dns:div/dns:table[2]/dns:tbody/dns:tr/dns:td[5]


2 Likes

Hi @sparel,

@umutcankurt has provided the correct XPath in the previous post.

I suggest using Firefox to find XPaths.

https://blog.statinfer.com/how-to-get-the-content-of-a-web-page-in-knime/

:blush:

2 Likes

@umutcankurt, Thanks! Seems to be doing what I was expecting, even if I don’t understand the full query.

2 Likes

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