What built in utilities are there that can evaluate XML XPath statements in CentOS?
Its needed to grab certain info from <a href="some.html">some</a> from a page with a python, perl or shell script.
Hints on what to use would be appreciated. Chris
On Fri, 8 Dec 2006 14:52:17 +0100 "Christian Nygaard" christiannygaard@gmail.com wrote:
What built in utilities are there that can evaluate XML XPath statements in CentOS?
libxml2 has XPath support. Bindings against libxml2 are provided by many languages, e.g. you could install the libxml2-python package from CentOS 4. Besides that, it is relatively easy to write a C program that uses libxml2 to evaluate XPath expressions (which is handy for shell scripting). A quick and dirty example can be found at:
http://danieldk.org/code/snippets/xpgrep-0.0.1.tar.gz
(I wrote/use it as a minimal grep workalike that accepts XPath expressions).
BTW. If you have files that are not well-formed (like many XHTML) files, or if the information to extract is trivial, it is often easier to grep or write a simple line-processing Perl script.
-- Daniel