I've found a workaround. If I copy(true) a node, then the required namespaces will be declared on the node. Here is a method that does what I want:
# creates a copy of each child before doing to_s # so that namespaces are properly declared def inner_xml_copy node, options = {} return (node.map { |n| n.copy(true).to_s options }.join '') end Tim Tim Olsen wrote: > Hello, > > I am trying to call Node#inner_xml() and have all namespaces referenced > in the inner xml be spit out as well, so that the returned string can be > parsed again. > > For example, take the following xml: > > <a:feed xmlns:a="http://www.w3.org/2005/Atom"> > <a:title a:type="text">Phil Bogle's Contacts</a:title> > </a:feed> > > I would like to be able to call inner_xml() on the feed node, and get: > > <a:title a:type="text" xmlns:a="http://www.w3.org/2005/Atom">Phil > Bogle's Contacts</a:title> > > Notice the namespace declaration now on the title node. > > I couldn't find an option to pass to inner_xml() (or to_s()) to do this. > I was thinking maybe I could modify what Namespaces#definitions() > returns but I couldn't find a method to modify the definitions. > > Any idea how to achieve this? > > Thanks, > Tim > _______________________________________________ > libxml-devel mailing list > libxml-devel@rubyforge.org > http://rubyforge.org/mailman/listinfo/libxml-devel _______________________________________________ libxml-devel mailing list libxml-devel@rubyforge.org http://rubyforge.org/mailman/listinfo/libxml-devel