xmlgrep(1) - Linux man page
Name
xmlgrep - searches XML files
Syntax
xmlgrep [options] [level] path
Description
Select subsets of xmlfiles for output.
- Format of path:
-
PATH = NODE(.NODE)*
NODE = NAME(:SELECTOR)*
SELECTOR = PROP(=|!=|~=)([*]|VALUE)
When using PCRE ( prop~=regex ) be careful to escape any '.'s. That is "ab.*z" must be given as "ab.*z".
Options
- -f file
-
Use file as input.
- -d delim
-
Use delim as output delimiter.
- -D delim
-
Replace delimiter with delim when encountered in the document.
- -x
-
Remove all text nodes.
- -q
-
Silent. Output nothing.
- -u
-
Keep UTF8 as output encoding of text.
- -g
-
Search globaly.
- -S
-
Do not invoke xmlserver.
- -K --killserver
-
Kill any active xmlserver on given file.
- -T
-
Make sure to print the XML documents topnode.
This is useful for stacked xmlgreps.
- -p
-
Do NOT prune unmatched nodes.
- -c
-
Output only children of the matched nodes (and at the matched level).
- -N
-
Loadtest. Do nothing after parsing xmlfile.
- -h, --help
-
Output help information and exit.
- -V, --version
-
Output version information and exit.
Exit Status
Exit with zero status if a match is found, otherwise exit with non-zero status.Examples
Test file:
<?xml version="1.0" encoding="ISO-8859-1"?>
<top>
<a>
<b u="kalle">B1</b>
</a>
<a>
<b>B2</b>
<c>C1<b>B3</b></c>
</a>
<m>
Some text here..
</m>
<multi u="groda" id="150"/>
<multi u="kalle" id="150"/>
</top>
Look for node sequence "top->a->b" (levelwise). Display from level 2.
$ xmlgrep -f test.xml 2 top.a.b
<b u="kalle">B1</b>
<b>B2</b>
Look for node "c" anywhere in tree.
$ xmlgrep -gf test.xml 0 c
<c>C1<b>B3</b></c>
Look for node "b" with property "u" with value "kalle".
$ xmlgrep -f test.xml 2 top.a.b:u=kalle
<b u="kalle">B1</b>
Node named multi where u is not "groda" and id is 150.
$ xmlgrep -gf test.xml 0 multi:u!=groda:id=150
<multi u="kalle" id="150"/>
Authors
Jens L��s <Jens.Laas@data.slu.se>