Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Are there any utilities similar to xpath for parsing XML files that would be natively available on a RedHat server?

Similar questions have been answered elsewhere, but none of the tools listed are on the server.

update: xmllint is installed, and man xmllint indicates that it can parse xml files, but it is not clear that this gives me the ability to extract a string from a specific node.

share|improve this question
up vote 2 down vote accepted

xsltproc (command line interface to libxslt) is always available on RHEL.
usage: xsltproc xsl_stylesheet xml_file.

share|improve this answer

If, given this XML

$ cat a.xml

You want to be able to do

$ ./xpath //a/b a.xml

then you could just cut & paste this:

$ cat xpath
use strict;
use warnings;
use XML::LibXML;

my $parser = XML::LibXML->new();
my $document = $parser->parse_file($ARGV[1]);
my @nodes = $document->findnodes($ARGV[0]);
for my $node (@nodes) {
  print $node->textContent, "\n";

You should be able to install the XML::LibXML module using perl -MCPAN -e 'install XML::LibXML'

share|improve this answer
Or just yum install 'perl(XML::LibXML)'. – Ignacio Vazquez-Abrams Apr 5 '11 at 14:28

Try xmllint and the --xpath option:


$ xmllint --xpath '//hello/text()'
share|improve this answer
Too bad that the "--xpath" option is only available on RedHat 7, which was not around when this question was posted. – chutz Jan 3 '15 at 14:50

XMLStarlet is in EPEL.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .