Output XML to File

I am trying to read some information based on a user id, then search the
database for the needed info and build an XML file. Everything seems to
be working fine; I read the info, I create the xml and even spit “stuff”
out to file. The issue is that the “stuff” I am writing to a file is a
xml/html cross cluster #@%$ of stuff. Here is some code:

if !params[:id].blank?
@user = User.find_by_id(params[:id])

@xml = ::Builder::XmlMarkup.new
@unusedtickets = Unusedticket.find(:all, :conditions => ['user_id =

? and
updated = true’, @user.id])
end

@xml.DocumentElemnts{
for unusedticket in @unusedtickets
@xml.unusedtickets do
@xml.account_id(unusedticket.account_id)
@xml.locator(unusedticket.locator)
@xml.ticketnumber(unusedticket.ticketnumber)
@xml.traveler(unusedticket.traveler)
@xml.issuedate(unusedticket.issuedate)
end
end
}

headers[“Content-Type”] ||= ‘text/xml’
headers[‘Cache-Control’] = ‘private’
headers[“Content-Disposition”] ||= “attachment; filename=“test_xml””
render :text => @xml, :layout => nil

I really thought that if I said :layout => nil that would strip away all
the html formatting, but apperantly not. Is there a way that I can write
this information to a file and have it be strictly XML? Thanks,

-S

How about:

puts User.find_by_id(params[:id]).to_xml

On Aug 4, 5:42 pm, Shandy N. [email protected]