I am having problems creating nodes and adding them to an XML file
<mainnode>
<secnode>
<data1></data2>
<data2></data2>
</secnode>
</mainnode>
i want to be able to add to the file like so
<mainnode>
<secnode>
<data1></data2>
<data2></data2>
</secnode>
<secnode>
<data1></data2>
<data2></data2>
</secnode>
</mainnode>
I am having trouble getting the concept of adding nodes with Nokogiri
current code:
def openXML
f = File.open("file.xml")
doc = Nokogiri::XML(f)
end
def parseXML
mainnode.name = 'mainnode'
f = openXML
temp = Nokogiri::XML::Node.new "secnode", f
mainnode.add_next_sibling(temp)
end
What concepts am i missing?
i need to be able to add instance variables to and but i am finding the nokogiri tutorial to not be of much help in this area and have not made it past just adding the node as a child of
any help is appreciated. comment if more info is needed
No comments:
Post a Comment