i have one xml file. lets say sample.xml with random position of tabs and spaces:
<T1>
<S1 > D1 </S1>
<S1>D2 </ S1>
< S2 >D3 </S2>
<S3> D4</S3>
</T1 >
I want to change data and format to something like this
<T1>
<S1>D5</S1>
<S1>D6</S1>
<S2>D7</S2>
<S3>D8</S3>
</T1>
I tried in sed, but it is not working for multiple line case as here.
How i can achieve same.
Remove all whitespace from the file and then format it using xmllint
Background
As pointed out by @choroba, your input data it not a valid XML file:
The xmllint command states why: