From: Rob Biedenharn Date: 2008-10-09T21:04:18+09:00 Subject: Re: Builder::XmlMarkup extra to_s tag On Oct 9, 2008, at 7:12 AM, ted wrote: > Hi, > > I'm trying to print out some xml and don't know what I'm doing. I'm > getting > this tag in the output. Where is it coming from and how do I > get rid > of it. Here's my test code. Any help appreciated. > > CODE: > require "builder" > class Fruit > attr_accessor :name > end > fruit = Fruit.new() > fruit.name = "Apple" > f = File.new("test.xml", "w") xml = Builder::XmlMarkup.new(:target=>f, :indent=>2) > xml.fruit do > xml.name(fruit.name) > end > > > OUTPUT: > > Apple > > > > > Thanks, > Ted or change your original to: f.print(xml.target!) The to_s comes from print getting something that is not a String and coercing it with to_s which the Builder object thinks is an empty tag. -Rob Rob Biedenharn http://agileconsultingllc.com Rob@AgileConsultingLLC.com