XML-FIND
XML-FIND
NAME
SYNOPSIS
DESCRIPTION
EXPRESSION
EXIT STATUS
EXAMPLE
AUTHORS
SEE ALSO
NAME
xml-find
− search for nodes in XML files and execute
actions.
SYNOPSIS
|
xml-find |
|
[ [FILE]...
[:XPATH]... ]... [EXPRESSION] |
|
DESCRIPTION
xml-find
searches the contents of FILE like a directory tree, and
evaluates the given EXPRESSION on each encountered tag. The
search starts at each XPATH associated with FILE, according
to the common unified command line convention described in
xml-coreutils(7). For each tag, the EXPRESSION is
evaluated from left to right and any actions are performed
as required, after which xml-find moves to the next
tag. If no EXPRESSION is specified, the EXPRESSION is
assumed to be -print.
EXPRESSION
An expression
is a sequence of actions to be performed in order for each
current node, while the XML document is being traversed.
Each action can be followed by zero or more arguments, and
also evaluates to true or false. When some action evaluates
to false, the subsequent actions are not evaluated. The
available actions are:
|
-print |
|
Prints the XPATH for the current node. |
|
-exec |
|
Execute PROGRAM with the optional list of ARG arguments.
The final semicolon indicates the end of arguments, and must
be supplied even if no arguments are given. There are three
special arguments, {} expands to the path for the currently
visited tag, {@} expands to a list of attributes and values
associated with the current tag, and {-} expands to the name
of a temporary file which contains a copy of the currently
visited node. Evaluates to true if PROGRAM returns zero, and
false otherwise. |
-execnode
Similar to -exec, but all paths
are relative to the current node.
|
-name |
|
Checks to see if the currently visited tag name matches
the shell glob PATTERN. Returns true on a match, false
otherwise. |
|
-path |
|
Checks to see if the path for the currently visited tag
matches the shell glob PATTERN. Returns true on a match,
false otherwise. |
|
’(’ |
|
Represents a block of actions. Returns true if every
optional ACTION returns true, and false otherwise. |
|
’!’ |
|
Negates the value of ACTION. Returns true if ACTION
returns false, and vice versa. |
ACTION1
Evaluates ACTION2 if and only
if ACTION1 returns true. Returns true if both ACTION1 and
ACTION2 evaluate to true, false otherwise.
ACTION1
Evaluates ACTION2 if and only
if ACTION1 returns false. Returns the value of ACTION1 if
true, or the value of ACTION2 otherwise.
EXIT STATUS
xml-find
returns 0 on success, or 1 otherwise.
EXAMPLE
Identify all
the tag addresses which match a given XPATH:
xml-find movies.rss :/rss/channel -print
For each
matching node, print all of its attributes:
xml-find movies.rss ://media:content -exec echo {@} ;
AUTHORS
Laird
A. Breyer is the original author of this software. The
source code (GPLv3 or later) for the latest version is
available at the following locations:
http://www.lbreyer.com/gpl.html
http://xml-coreutils.sourceforge.net
SEE ALSO
xml-coreutils(7)
|