看起来答案是否定的;不像图书馆目前所写的,也许根本不是。跟踪呼叫路径为节点的序列化:
Nokogiri::XML::Node#to_s
电话to_xml
Nokogiri::XML::Node#to_xml
电话serialize
(设置了几个默认选项)
Nokogiri::XML::Node#serialize
电话write_to
Nokogiri::XML::Node#write_to
电话native_write_to
Nokogiri::XML::Node#native_write_to
电话native_write_to
,看起来像th是:
&bsp;
def native_write_to(io, encoding, indent_string, options)
set_xml_indent_tree_output 1
set_xml_tree_indent_string indent_string
savectx = LibXML.xmlSaveToIO(IoCallbacks.writer(io), nil, nil, encoding, options)
LibXML.xmlSaveTree(savectx, cstruct)
LibXML.xmlSaveClose(savectx)
io
end
所以,你在libxml的摆布在这一点上。谷歌搜索libxml serialize single quote attributes不会立即启动任何吸烟枪。
我想你应该file a feature request,看看你能得到什么样的tenderlovin。 :)
关于_“或保留任何引用样式在原来的”_参见[可以Nokogiri保留属性引用样式?](http://stackoverflow.com/q/8424858/405017) – Phrogz 2011-12-08 17:12:41