format an xml string in Ruby

Posted by user1476512 on Stack Overflow See other posts from Stack Overflow or by user1476512
Published on 2012-09-26T09:25:17Z Indexed on 2012/09/26 9:38 UTC
Read the original article Hit count: 235

Filed under:
|
|

given an xml string like this :

<some><nested><xml>value</xml></nested></some>

what's the best option(using ruby) to format it readable like :

<some>
  <nested>
    <xml>value</xml>
  </nested>
</some>

I've found an answer here: what's the best way to format an xml string in ruby?, which is really helpful. But it formats xml like:

<some>
  <nested>
    <xml>
      value
    </xml>
  </nested>
</some>

As my xml string is a little big in length. So it is not readable in this format.

Thanks in advance!

© Stack Overflow or respective owner

Related posts about ruby

Related posts about Xml