Skip to main content
3 of 8
added 197 characters in body
Aryise
  • 63
  • 1
  • 1
  • 5

how to parse xmlfile in shellscript

I would like to know how can I split my data from the following format:

<datas>
 <data>
  <name>Name1</name>
 </data>
 <data>
  <name>Name2</name>
 </data>
</datas>

to the following format.

<data><name>Name1</name></data>
<data><name>Name2</name></data>

I have tried commands like echo 'cat /datas/data' | xmllint --shell file.xml but I do not know how to store in a variable and use for loop to print it out

or other means to achieve the same results

Aryise
  • 63
  • 1
  • 1
  • 5