![JAR search and dependency download from the Maven repository](/logo.png)
scriptella.driver.xpath.package.html Maven / Gradle / Ivy
XPath Driver for Scriptella.
Allows querying an XML file based on XPath expressions.
General information
Driver class: scriptella.driver.xpath.Driver
URL: XML file URL. URIs are resolved relative to a script file directory.
Runtime dependencies: None
Driver Specific Properties
Name
Description
Required
trim
Value of true
specifies that the leading and trailing
whitespaces in text file lines should be omitted..
No, the default value is true
.
Query Syntax
XPath driver supports XPath syntax to query text files.
The query is executed on a 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 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 value of variable A represents text content inside XML element <A>,
the value of variable B represents value of B attribute and
the value of variable C represents text content inside element <C>.
Additional notes:
- Currently only Node Set can be selected in XPath expressions, i.e. attributes or elements but not String, Boolean or Number
Script Syntax
<script> elements are not supported by the driver.
Properties substitution
In query elements ${property} or $property syntax is used for properties/variables substition.
Examples
<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.
© 2015 - 2025 Weber Informatics LLC | Privacy Policy