From: Michael Fellinger Date: 2007-12-11T21:49:48+09:00 Subject: Re: REXml help - Insert newlines into large xml file On Dec 11, 2007 1:50 PM, Phrogz wrote: > On Dec 10, 8:35 pm, 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. > > For the record, would you care to clarify and justify that statement? Sure, i've tried for quite some time to get REXML to a point where it really pretty-prints any document, but apart from implementing a whole streamlistener that keeps track of indentation and width there doesn't seem to be any. The new REXML works a bit better but inserts lots of whitespace at the wrong places. Unfortunately tidy has a memory-leak, so i cannot recommend the bindings if your process is running over a longer period. Of course you could start it in another process, but then the CLI tool is good enough already. REXML::VERSION # "3.1.6" http://pastie.caboo.se/126905 ^ manveru