Your example does not make sense; you say you want to βencodeβ and then try to write βencodedβ.
, XML. encode content, content. <content:encode>text</content:encode>, <encode:content>text</encode:content>. ( ?)
. content encoded, , :
xml['encoded'].content{ xml.text "text" }
, , , . :
require 'nokogiri'
builder = Nokogiri::XML::Builder.new do |xml|
xml.root('xmlns:encoded' => 'bar') do
xml['encoded'].content{ xml.text "text" }
end
end
puts builder.to_xml
. , Nokogiri . :
str = "Hello World"
xml = "<encoded:content>#{str}</encoded:content>"
puts xml
Nokogiri, - , :
xml_str = builder.doc.root.children.first.to_s
share