I have the following XML format
<object class="Class A">
<directory>someString1</directory>
<attr>
<name>length</name>
<value>6</value>
</attr>
<attr>
<name>parent</name>
<value>1</value>
</attr>
<attr>
<name>Status</name>
<value>1</value>
</attr>
<attr>
<name>className</name>
<value>Class A</value>
</attr>
<attr>
<name>Instance</name>
<value>InstanceValue</value>
</attr>
</object>
...
<object class="Class D">
<directory>someString4</directory>
<attr>
<name>length</name>
<value>8</value>
</attr>
<attr>
<name>parent</name>
<value>1</value>
</attr>
<attr>
<name>Status</name>
<value>1</value>
</attr>
<attr>
<name>className</name>
<value>Class D</value>
</attr>
<attr>
<name>Instance</name>
<value></value>
</attr>
</object>
....
I need to find particular class D object only and find whether Instance value is empty for that object, If empty fill up with some value provided as an argument. Please note that there can be multiple objects in the XML file and XML tags name and value are quite a bit repeated. Further, I need to do it with shell scripting only on suse Linux.
I am new to shell scripting and SED. I tried my level best to find existing questions and answers in stackoverflow, but coulnd't find a relevant one. Any help is highly appreciated.
xsltproc, which many Linux distributions are shipping out-of-the-box these days).