Class | Description |
---|---|
Driver |
Represents a driver for querying XML files with XPath expressions.
|
NodeVariable |
A special
node variable for sub-queries and scripts that wraps
the node selected by an XPath query, exposing useful methods. |
XPathConnection |
Represents a connection to an XML file.
|
XPathQueryExecutor |
Executor for XPath queries.
|
Exception | Description |
---|---|
XPathProviderException |
Thrown to indicate a problem with XML file querying.
|
Driver class: | scriptella.driver.xpath.Driver |
URL: | XML file URL. URIs are resolved relative to a script file directory. |
Runtime dependencies: | None |
Name | Description | Required |
---|---|---|
return_arrays | Value of true specifies that variables should
return a string array, otherwise a single string is returned.
| No, the default value is false . |
The query is executed on an XML Document and produces a rowset for matched nodes. The attribute and element values can be referenced from nested scripts/queries. The following example illustrates the querying mechanism:
Example:
XPath: /A
selects root element <A>
<A B="1"> <B>2</B> <C>3</C> </A>Available variables for matched element <A>:
Name | Value |
---|---|
A | 2 3 |
B | 1 |
C | 3 |
The context node for the XPath query is the selected node of the nearest outer XPath query, or the document root node if there isn't one. This allows relative queries using ./
A special node
variable is available to the nested queries/scripts which provides extra methods for querying relative to the current node. The node variable is an instance of NodeVariable
. Using ${node.getString("./C")}
is equivalent to $C
.
Additional notes:
<connection id="in" driver="xpath" url="data.xml"/>
<connection id="out" driver="text" url="report.csv"/>
<query connection-id="in">
/HTML/BODY/TABLE/TR
<script connection-id="out">
$rownum;${td[0]};${td[1]}
</script>
</query>
Extracts rows from tables in data.xml file and produces report.csv.Copyright © Copyright 2006-2019 The Scriptella Project Team.