Revision [945]

This is an old revision of CommandXpath made by DavidLee on 2009-11-24 18:33:43.


Command xpath


xpath evaluate an XPATH expression and print the result


xpath [ serialization options ] [options] [xpath-expr]


if input is an XML expression then use it directly (dont treat as filename).
-f xpath-file
-file xpath-file
read xpath expression from file
-input input
-i input
use input as the source xml document, otherwise stdin
-n do not use a source context
-q xpath-expr
-query xpath-expr
xpath expression
-v Read remaining pairs of arguments as name/value pairs to assign as xpath variables
-nons Do not import global namespace declarations from the shell environment
-ns prefix=uri Add a predeclared namespace delcaration
Convert the result to a string if it is an attribute or element
Do not print anything. Treat the result as a boolean and exit with 0 if the value is true otherwise 1
-eExecute xpath but do not print anything. The exit status is 0 if there was any selected values otherwise 1

Supports the standard [ serialization options ]

Note that the "-q" is optional. It is only required if you need to specify both -n and -v
xpath-n -q expr -v variable some-value


xls | xpath '//file[1]/@name/string()'


Namespace example using a renamed prefix for a namespace
echo "<x:a xmlns:x='foo' />" | xpath  -nons -ns y=foo /y:a

<x:a xmlns:x="foo"/>

Return Value

Returns 0 if the the xpath expression executed successfully and a non-empty result is returned. otherwise 1

There are no comments on this page.
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki