How to add Nokogiri::XML::Element to an XML document created using Nokogiri::XML::Buider ?
My current solution is to serialize the element and use the << method so that Builder interprets it.
orig_doc = Nokogiri::XML('<root xmlns="foobar"><a>test</a></root>') node = orig_doc.at('/*/*[1]') puts Nokogiri::XML::Builder.new do |doc| doc.another {
However, Nokogiri::XML::Element is a rather large node (in kilobyte order and thousands of nodes), and this code is in a hot way. Profiling shows that serializing / disassembling both ways is very expensive.
How can I tell Nokogiri Builder to add an existing node XML element to the "current" position?
source share