Wednesday, September 1, 2010

How to use LibXML on rails

xml_doc = LibXML::XML::Document.new
xml_doc.root = LibXML::XML::Node.new("node_name")
xml_doc.root['id'] = id.to_s
xml_doc.root << xml_ex1 = LibXML::XML::Node.new("ex1")
xml_doc.root << xml_ex2 = LibXML::XML::Node.new("ex2")
#my method to convert an array into a filler of the ex1 node
self.push_this_array_into_this_node(notifications, xml_ex1, "notification")
#my method to convert an array into a filler of the ex2 nodeself.push_this_array_into_this_node(requests, xml_ex2, "request")
return xml_doc

No comments:

Post a Comment