Confusion with Nokogiri node method "to_xml"

17 views
Skip to first unread message

Arup Rakshit

unread,
Feb 19, 2014, 2:43:34 PM2/19/14
to nokogi...@googlegroups.com

require 'nokogiri'
xml= "<s:Some xmlns:s=\"http://nmsc.com/nmsc\"><s:One></s:One></s:Some>"
n= Nokogiri.XML(xml)
node = n.xpath("//s:One", :s=>"http://nmsc.com/nmsc")[0]
puts node.to_xml(:save_with => Nokogiri::XML::Node::SaveOptions::DEFAULT_XML )
# >> <s:One/>

But I wanted the output as :

<s:One xmlns:s="http://nmsc.com/nmsc" />

How to do this ?
Reply all
Reply to author
Forward
0 new messages