Skip to main content
4 of 10
edited title
αғsнιη
  • 41.9k
  • 17
  • 75
  • 117

Extract data between two xml tag

Extract data between two xml tag.

Xml File :-

<instance ab=1 >
<a1>a1<a1>
    <a2>a2<a1>
<instance>
<instance ab=2 >
<b1>a1<b1>
    <b2>a2<b1>
</instance>
<instance ab=3 >
<c1>a1<c1>
    <c2>a2<c2>
</instance>

Looking for output by using sed or awk like following

<a1>a1</a1><a1>a1</a1>
<b1>a1</b1><b2>a2</b1>
<c1>a1</c1><c2>a2</c2>

Please help me.

It's not working with following sed program. sed -n '/<Sample/,/</Sample/p' ab

Abhi S
  • 31
  • 1
  • 4