Reformating xml document

Posted by Joseph Reeves on Ask Ubuntu See other posts from Ask Ubuntu or by Joseph Reeves
Published on 2012-06-18T09:11:34Z Indexed on 2012/06/18 9:24 UTC
Read the original article Hit count: 512

Filed under:
|

I have an xml document in the format below:

  <key>value</key>
  <key>value</key>
  <key>value</key>

But need to convert it to the following:

  <tag k='key' v='value' />
  <tag k='key' v='value' />
  <tag k='key' v='value' />

The original xml file is roughly 20,000 lines long, so I'm keen to automate as much as possible! I've looked at xmlstarlet, but drew a blank with it. Presumably it would be a good place to start though? Help gratefully received, thanks.

© Ask Ubuntu or respective owner

Related posts about conversion

Related posts about Xml