From: Aaron Patterson Date: 2009-09-16T01:29:54+09:00 Subject: Re: Formatting REXML On Sep 15, 2009, at 12:48 AM, Charles Roper wrote: > Hey all, > > I posted a question on StackOverflow the other day that I thought > would be reasonably easy to answer, but actually, I got nothin', > zilch, nada. Rather than repeat the question here, here's the link: > > http://bit.ly/tN7FK > > I don't mind if there's a way of formatting the XML with something > other than REXML - whatever achieves the result is good with me. Any > help would be really welcome as I've spend *ages* now trying to do > this one stupid thing. FTFY require 'rubygems' require 'nokogiri' doc = Nokogiri::XML(DATA.read) { |cfg| cfg.noblanks } Nokogiri::XML::Builder.new do |xml| xml.doc = doc xml.parent = doc.at('dict') xml.key('gutter') xml.string('#282828') end puts doc.to_xml __END__ background #FFFFFF caret #000000 foreground #000000 invisibles #BFBFBF lineHighlight #00000012 selection #BAD6FD Doesn't use REXML, but does output the formatting you want. Hope that helps! --- Aaron Patterson http://tenderlovemaking.com