Wednesday, 28 August 2013

Access attribute specified by XPath with xml_grep

Access attribute specified by XPath with xml_grep

How can I access the value of an attribute specified via XPath with xml_grep?
I've tried:
# svn info http://unladen-swallow.googlecode.com/svn/trunk/ --xml > x
# cat x
<?xml version="1.0"?>
<info>
<entry
kind="dir"
path="trunk"
revision="1171">
<url>http://unladen-swallow.googlecode.com/svn/trunk</url>
<repository>
<root>http://unladen-swallow.googlecode.com/svn</root>
<uuid>05521daa-c0b4-11dd-bb00-bd6ab96fe29a</uuid>
</repository>
<commit
revision="1171">
<author>ebo@4geeks.de</author>
<date>2010-08-21T18:17:31.382601Z</date>
</commit>
</entry>
</info>
# xml_grep uuid x --text_only
05521daa-c0b4-11dd-bb00-bd6ab96fe29a
# xml_grep //info/entry/@path x --text_only # correct XPath syntax
error: unrecognized expression in handler: '//info/entry/@path' at
/usr/bin/xml_grep line 198
# xml_grep //info/entry/[@path] x --text_only
# # no output
I've looked at the online help pages, but the only syntax that matches a
property at all is far too verbose:
# xml_grep '*[@path]' x
<?xml version="1.0" ?>
<xml_grep version="0.7" date="Wed Aug 28 15:22:13 2013">
<file filename="x">
<entry kind="dir" path="trunk" revision="1171">
<url>http://unladen-swallow.googlecode.com/svn/trunk</url>
<repository>
<root>http://unladen-swallow.googlecode.com/svn</root>
<uuid>05521daa-c0b4-11dd-bb00-bd6ab96fe29a</uuid>
</repository>
<commit revision="1171">
<author>ebo@4geeks.de</author>
<date>2010-08-21T18:17:31.382601Z</date>
</commit>
</entry>
</file>
</xml_grep>
#
What's the correct syntax?

No comments:

Post a Comment