Revision [305]
This is an old revision of CommandXpath made by DavidLee on 2008-11-21 10:21:57.
Command xpath
Name
xpath evaluate an XPATH expression and print the resultSynopsis
xpath [-f xpath-file] [-i input-file] [-n] [-nons] [-ns prefix=uri [-ns ..]] [-q] xpath-expr [-v name value [name value ...]]Description
-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).
[-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
Examples
xpath-n -q expr -v variable some-value
Example
$ xls | xpath '//file[1]/@name' name=".classpath"
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 1CategoryCommands