Extract Root Element Name from XML

How do you use XPath to extract the root element's name from XML?

I could do this in KNIME 2.11 using the (now deprecated) XPath node with this instruction:

name(/*)

But this no longer seems to work with the new KNIME 2.12 XPath node. I am now getting the exception:

Execute failed: javax.xml.xpath.XPathExpressionException: 
org.apache.xpath.XPathException: 
Can not convert #STRING to a NodeList!

The exception implies that I'm trying to output a String to a NodeList, but the node's output has been set to be a String and none of the NodeList options seem to work. I've attached a workflow to illustrate the problem.

Is this a bug?

 

Hi Edlueze,

yes this is a bug I just verified it with 2.11 (where it does work) and reported it to the developers. Thank you for reporting it!

Best regards, Iris

Hi Iris,

I am also looking for root element name from xml.

So, could you please update here, once it is fixed and provide the steps also to get that.

Thanks in advance.

BR,

Velu

 

 

Hi Velu,

I'll keep you updated.

Best,

Jon

Hi Velu and Edlueze,

As Iris said the bug was verified. We now made a bugfix and are testing internally. That means that this should make it into the next bugfix release of KNIME.