1
Given the following input:
<start>
<header>
This is header section
</header>
<body>
<body_start>
This is body section
<a>
<b>
<c>
<st>111</st>
</c>
<d>
<st>blank</st>
</d>
</b>
</a>
</body_start>
<body_section>
This is body section
<a>
<b>
<c>
<st>5</st>
</c>
<d>
<st>666</st>
</d>
</b>
<b>
<c>
<st>154</st>
</c>
<d>
<st>1457954</st>
</d>
</b>
<b>
<c>
<st>845034</st>
</c>
<d>
<st>blank</st>
</d>
</b>
</a>
</body_section>
</body>
</start>
I'd like to perform the following parsing.
If st
value of c
tag is 154
, then the whole <b>
to </b>
tag needs to removed. Note that value 154 may or not be present in the file.
So, if the value 154 is present, then the removal of the following part is needed:
<b>
<c>
<st>154</st>
</c>
<d>
<st>1457954</st>
</d>
</b>
I want to do the coding in a shell script. I can not use xslt
because my system does not support it.
I think
sed
isn't the ideal tool for this task. You should use perl, php or similar language - or a xml-releated tool. – uzsolt – 2017-01-18T08:33:54.8204Why inventing a bicycle if nearly all unix based system has in their repos
xmlstarlet
? – Alex – 2017-01-18T08:35:45.727