¿Cómo manejar ' en XML con nokogiri?
Frecuentes
Visto 230 veces
1
I am generating a XML file with the following the key/values using nokogiri XML builder.
<customize>
<key>[@email='enter_your_email']</key>
<string>foo@gmail.com</string>
</customize>
1.When viewing the generated XML file in browser, it doesn't show '
as ' in browser, it just shows as <key>[@email='enter_your_email']</key>
2.when viewing generated the XML file as text, it shows
<key>[@email=&apos;enter_your_email&apos;]</key>
Is there any way to remove the amp; when generating XML file? Help me to solve this.
build = Nokogiri::XML::Builder.new do |xml|
xml.customize {
xml.key{ |x| x.text "[@email='enter_your_email']"}
xml.string{ |x| x.text "foo@gmail.com"}
}
end
build.to_xml
1 Respuestas
1
I am not quite sure if this helps.
require 'nokogiri'
doc = Nokogiri::XML::Document.new
doc.encoding = 'UTF-8'
puts doc.fragment("<customize>
<key>[@email='enter_your_email']</key>
<string>foo@gmail.com</string>
</customize>")
#=> <customize>
<key>[@email='enter_your_email']</key>
<string>foo@gmail.com</string>
</customize>
respondido 27 nov., 13:06
No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas ruby xml ruby-on-rails-3 nokogiri or haz tu propia pregunta.