# Formatting XML with Nokogiri

**URL:** <https://www.ruby-forum.com/t/formatting-xml-with-nokogiri/176135>\
**Category:** Ruby\
**Created:** [September 25, 2009, 3:21am UTC](https://www.ruby-forum.com/t/formatting-xml-with-nokogiri/176135 "2009-09-25T03:21:24Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![viatropos](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/8baadc/32.png) [@viatropos](https://www.ruby-forum.com/u/viatropos)\
**Post date:** [September 25, 2009, 3:21am UTC](https://www.ruby-forum.com/t/formatting-xml-with-nokogiri/176135/1 "2009-09-25T03:21:24Z")

</div>

What’s the best/recommended way to format XML with nokogiri?

I would like to be able to have all the nodes indented with a “\t”  
instead of " " two spaces, and have max two attributes per line.

Do I have to use regular expressions on the xml string with gsub or is  
there a better alternative?

Thanks,  
Lance
