I have a large XML file with several tags.
One of the sub tag is as below:
<Products>
<SubProduct> ----> this line is problem
<SubProduct>
<Name>One</Name>
</SubProduct>
<SubProduct>
<Name>One</Name>
</SubProduct>
<SubProduct>
<Name>One</Name>
</SubProduct>
<SubProduct>
<Name>One</Name>
</SubProduct>
<SubProduct>
<Name>One</Name>
</SubProduct>
</SubProduct> ----> this line is problem
</Products>
As seen above, the Products tags will have multiple SubProduct tags.
However, an extra SubProduct opening and closing tag is appearing as mentioned above (with comment 'this line is problem').
The solution would be to search for two consecutive open SubProduct tags and two consecutive close SubProduct tags and replace one in each with space.
How can I achieve this using sed
?
How can I search for two consecutive tags where the tags are on separate lines as well as I do not know how many spaces will be present between the two consecutive tags (it could be 5 spaces or 10 spaces before or after the new line character).