Extend existing XML by Nokogiri

CripingtonVog

New Member
I'm trying to extend an existing XML file and add a new node. I'm loading the XML containing a lot of products, add a new one and save it.I'm using Nokogiri and Ruby 1.9.3.This is the best that I created:\[code\]builder = Nokogiri::XML::Builder.new do root do load_xml = Nokogiri::XML(IO.read("test.xml")) parent.add_child(load_xml.root) data do name "Name" end endendfile = File.open("test.xml",'w')file.puts builder.to_xmlfile.close\[/code\]
 
Back
Top