Welcome to Dream.In.Code
Getting Help is Easy!

Join 117,162 Programmers for FREE! Ask your question and get quick answers from experts. There are 2,451 online right now! We've got more than 500 tutorials and 2,000 snippets. Join and find out why Dream.In.Code is the #1 programming help community on the internet! Registration is fast and FREE... Join Now!



xml inside an xml document

 
Reply to this topicStart new topic

xml inside an xml document, embedded xml

spullen
post 8 Jun, 2007 - 03:46 PM
Post #1


D.I.C Regular

Group Icon
Joined: 22 Mar, 2007
Posts: 330



Dream Kudos: 50
My Contributions


OK, so I have this little problem with creating an xml document.
I am overiding the to_xml method inside a model that I have, and it looks like this:
CODE

class Model < ActiveRecord::Base
#database definitions, and table relationships

def to_xml
   xml = Builder::XmlMarkup.new(:indent => 2)
   xml.instruct!
   xml.details do
        xml.tag!(:name,  self.name)# where self calls the data in the column of a database (this works fine), and :name is the name of the column
        xml.tag!(:street, self.street.to_xml) # this is where is gets caught up * (references a table that is foreign to the table of Model, which is another model (obviously))
   end
end
end

*: this is how I was trying to do it, and for the most part it works, except it just takes the xml doc generated and makes it into a string and puts it into the node details, so when I want to parse it, it won't work.

So I guess my question is there a way to insert nodes from another model's table that is joined to the table of the model (set up using belongs_to method)?
User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 10/6/08 11:07AM

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month