Parse the XML file using the XML_GREP command in Linux

Home > Search > Linux commands

Let's say you have an XML file named example.xml with the following.



The xml_grep command can be used to parse the XML file for certain data.

~]# xml_grep 'id' example.xml
<?xml version="1.0" ?>
<xml_grep version="0.9" date="Thu Aug 17 20:59:36 2017">
<file filename="example.xml">


By default, xml_grep will display quite a bit of output. The --text_only option can be used to only display the value in a certain XML tag.

~]# xml_grep 'id' example.xml --text_only


Add a Comment

We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.

Please enter in the box below so that we can be sure you are a human.