Revision [355]

This is an old revision of CommandXpath made by DavidLee on 2009-01-03 07:11:54.


Command xpath


xpath evaluate an XPATH expression and print the result


xpath [-f xpath-file] [-i input-file] [-n] [-nons] [-ns prefix=uri [-ns ..]] [-q] xpath-expr [-v name value [name value ...]]


-f xpath-file read xpath expression from file
-i input use input as the source xml document, otherwise stdin
if input is an XML expression then use it directly (dont treat as filename).
-n do not use a source context
[-q] 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

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'

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