Hi,
>> doc is an instance of Nokogiri::XML::DocumentFragment, and I checked
http://nokogiri.org/Nokogiri/XML/DocumentFragment.html and found:
>>
>> - Class Nokogiri::XML::DocumentFragment inherits from Nokogiri::XML::Node
>> - to_xml(*args) Convert this DocumentFragment to xml See Nokogiri::XML::NodeSet#to_xml
>>
>> I am puzzled whether DocumentFragment is a node or nodeset, and how does it differ in terms of to_xml(encoding: 'UTF-8').
As you say, DocumentFragment inherits Node,
but DocumentFragment#to_xml behaves like NodeSet#to_xml(which calls
#to_xml of children)
because it usually includes some child nodes, so the documentation
refers the latter.
I guess like above.
> I have figured this out, doc.to_xml(encoding: 'UTF-8') works as well. doc remains the same, but the output string has the correct encoding now. Thanks! Yi
Yes, doc is not changed because #to_xml is non-destructive method.
It was better if I wrote "puts doc.to_xml(encoding: 'UTF-8')."
Sorry for my description not enough to describe well,
and pleased to hear you resolved your problem.
KITAITI Makoto
2012/11/10 Yi Lv <
yi...@yahoo.com>
> --
> You received this message because you are subscribed to the Google Groups "nokogiri-talk" group.
> To view this discussion on the web visit
https://groups.google.com/d/msg/nokogiri-talk/-/O4HXuM5GhQUJ.
>
> To post to this group, send email to
nokogi...@googlegroups.com.
> To unsubscribe from this group, send email to
nokogiri-tal...@googlegroups.com.
> For more options, visit this group at
http://groups.google.com/group/nokogiri-talk?hl=en.