From: Jari Williamsson Date: 2007-12-11T17:32:59+09:00 Subject: Re: REXml help - Insert newlines into large xml file Michael Fellinger wrote: > On Dec 11, 2007 10:54 AM, Sean Nakasone wrote: >> Hello, I have a large xml file that does not have any newlines in it. Can >> someone please provide some code to use REXML to simply read in an xml, >> insert newlines after the xml sections or elements, then spit it out to >> stdout. This way I'd at least be able to open the xml file in an editor >> so I can read what kind of format it has. I don't know anything about >> REXML so it needs to be a somewhat complete script. thank you. > > Step 1) Install tidy > Step 2) tidy -i yourfile.xml > Step 3) tidy --help > > REXML is very bad for handling such things. Not at all. If you're using an an older version of the standard library, you prettify the XML using doc.write(output, 0), as in Phrogz' example. For newer versions of REXML, use the REXML::Formatter class instead which gives you much more control over the prettifier. Best regards, Jari Williamsson