I have the following code:
builder = Nokogiri::XML::Builder.new(:encoding => 'UTF-8') do |xml|
xml.myRoot do |xml|
xml.oneChild
xml.anotherChild
end
end
Now I want to append a few child nodes to myRoot using the builder (in a second step, I know how to append them straight away). How can I do that?
I've tried this:
node = builder.doc.xpath('//myRoot/oneChild').first
Nokogiri::XML::Builder.with(node) do |xml|
xml.childOfOneChild 'Im a child of oneChild'
end
Which doesn't work. They won't stick to the element, it's just an empty oneChild.