0 ×

XPath

StreamableKNIME XML version 4.0.0.v201905311239 by KNIME AG, Zurich, Switzerland

The node takes the XML Documents of the selected column and performs XPath queries on them. The node supports XPath 1.0.

XPath Syntax

Selection Nodes

ExpressionDescription
nodenameSelects all nodes with the name "nodename"
/Selects from the root node.
//Selects nodes in the document from the current node that match the selection no matter where they are
.Selects the current node
..Selects the parent of the current node
@Selects attributes

Predicates

Path ExpressionResult
/bookstore/book[1]Selects the first book element that is the child of the bookstore element.
/bookstore/book[last()]Selects the last book element that is the child of the bookstore element
/bookstore/book[last()-1]Selects the last but one book element that is the child of the bookstore element
/bookstore/book[position()<3]Selects the first two book elements that are children of the bookstore element
//title[@lang]Selects all the title elements that have an attribute named lang
//title[@lang='en']Selects all the title elements that have a "lang" attribute with a value of "en"
/bookstore/book[price>35.00]Selects all the book elements of the bookstore element that have a price element with a value greater than 35.00
/bookstore/book[price>35.00]/titleSelects all the title elements of the book elements of the bookstore element that have a price element with a value greater than 35.00

Syntax description from w3cschools.com.

Hint for streaming: Node can only be executed in real streamed fashion if every single XPath query is configured as follow (see XPath Query Settings):
The column names are fixed (i.e. select 'new column name') and either 'Single Cell', 'Collection Cell', or 'Multiple Rows' are selected as 'Multiple tag option'.

Options

Settings

XML column
The column containing the XML cells.
Remove source column
Check when the source column should not show up in the output table.
XPath summary
A summary of all defined XPath queries.
Add XPath
Opens a new dialog with the XPath query set XPath query of the selected XML element.
Eidt XPath
Edit a selected XPath query of the summary table.
Remove XPath
Remove a selected XPath query of the summary table.
XML-Cell Preview
Preview of the first not missing XML-Cell of the selected XML column. If a XML element is selected a right click can be performed to add a new XPath query.
Note: Only the first 2000 lines of the input XML cell are displayed.

Namespace

Namespaces
The prefixes and the namespaces used in the XPath query. For the example when querying XHTML documents with the XPath Query:
//pre:h1
the following namespace must be defined:
Prefix: pre
Namespace: http://www.w3.org/1999/xhtml
Note: The namespaces are collected automatically.
Incorporate namespace of the root element.

This option is useful when you do not have the default namespace of your document at hand.

If checked, the namespace of the root element is added to the Namespaces table during runtime. Please define a prefix for this namespace in Prefix of root's namespace.

For the example of XHTML documents the namespace of the root element is http://www.w3.org/1999/xhtml so that with the root's prefix of pre you can leave the Namespaces table empty.

Input Ports

Input table containing at least one XML column.

Output Ports

The input table with additional columns containing the result of the XPath queries.

Best Friends (Incoming)

Best Friends (Outgoing)

Workflows

Installation

To use this node in KNIME, install KNIME XML-Processing from the following update site:

KNIME 4.0
Wait a sec! You want to explore and install nodes even faster? We highly recommend our NodePit for KNIME extension for your KNIME Analytics Platform.

Developers

You want to see the source code for this node? Click the following button and we’ll use our super-powers to find it for you.