I have a XML file like below, I am trying to retrieve the first child node name and store it in an array and use it for reading the attributes.
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="config.xsl"?>
<cell name="servicesPrd">
<env>Prod </env>
<console>
...
</console>
<vhosts>
....
</vhosts>
<clusters>
....
</clusters>
<nodes>
....
</nodes>
</cell>
I am looking to retrieve env, console, vhosts, cluster, nodes through shell script
BTW I am able to read the node attributes using xmllint which is working fine, currently hardcoded the nodenames to it.
xmlstarlet
is generally useful for querying XML files: