Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to instal/setup XMLStarlet in Linux?

I'm fairly new to Linux and shell scripting; and have a requirement to parse and query an xml. I was able to find and use XML starlet for Windows successfully.

However, my goal is to have that run on Linux via a shell script.

Can anyone please share the steps to install and configure XMLStarlet on Linux?

Thanks!

like image 580
Rishi Avatar asked Mar 17 '17 11:03

Rishi


People also ask

What is XMLStarlet in Linux?

XMLStarlet is a set of command line utilities (tools) which can be used to transform, query, validate, and edit XML documents and files using simple set of shell commands in similar way it is done for plain text files using UNIX grep, sed, awk, diff, patch, join, etc commands.

How do I know if XMLStarlet is installed?

So, open a terminal (or other command line interface) and execute xpath . Since most terminals (or other command line interfaces) have auto-completion you could also simply type xpa and press tab . If it autocompletes to xpath , then you know it is installed.


1 Answers

For Ubuntu:

sudo apt-get update
sudo apt-get install xmlstarlet

For CentOS: It is present in epel repo, download the repo and enable it

sudo yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm

Confirm if it is enabled or not

cd /etc/yum.repos.d
grep -re enabled=1

This should show

epel.repo:enabled=1

Then Download xmlstarlet

sudo yum -y install xmlstarlet
like image 181
Ismail Avatar answered Sep 18 '22 18:09

Ismail