With the following input sample extracted from a xml file
<rel ver="123">
<mod name="on">
<node env="ac" env="1">
<ins ip="10.192.0.1"/>
<ins ip="10.192.0.2"/>
</node>
<node env="ac" env="2">
<ins ip="10.192.0.3"/>
<ins ip="10.192.0.4"/>
</node>
<node env="pr">
<ins ip="10.192.0.5"/>
<ins ip="10.192.0.6"/>
</node>
</mod>
<mod name="off">
<node env="ac" env="1">
<ins ip="10.192.0.7"/>
</node>
<node env="ac" env="2">
<ins ip="10.192.0.8"/>
</node>
<node env="pr">
<ins ip="10.192.0.9"/>
</node>
</mod>
</rel>
I was wondering if someone can help me having the following output:
123 env off on
ac1 10.192.0.7 10.192.0.1 10.192.0.2
ac2 10.192.0.8 10.192.0.3 10.192.0.4
pr 10.192.0.9 10.192.0.5 10.192.0.6
It's kind of easy getting ride of all xml tags (ex below code) but I have no idea how to produce the desired output table
awk -F '[\"/>]' '/rel ver/{print $2}/mod name/{print $2}/node env/{print $2, $4}/ins ip/{print $2}' file.xml
Thanks for your help