1

を使用してすべてのエンティティが殺されているようです

tags = "<p>test umlauts &ouml;</p>"
Nokogiri::XML.fragment(tags)

結果:

<p>test umlauts </p>

上記のメソッドが呼び出しNokogiri::XML::DocumentFragment.parse(tags)、そのメソッドが を呼び出します Nokogiri::XML::DocumentFragment.new(XML::Document.new, tags)

nokogiri ドキュメントに関しては、次のコードが実行されます。

def initialize document, tags=nil
    if tags
      parser = if self.kind_of?(Nokogiri::HTML::DocumentFragment)
                 HTML::SAX::Parser.new(FragmentHandler.new(self, tags))
               else
                 XML::SAX::Parser.new(FragmentHandler.new(self, tags))
               end
      parser.parse(tags)
    end
end

XML::SAX::Parser と対応する FragmentHandler を扱っていると思います。コードを掘り下げてもヒントはありません。正しい結果を得るには、どのパラメーターを設定する必要がありますか?

4

1 に答える 1

3

oouml is not a predefined entity in XML. If you want to allow the HTML entity references in XHTML you'd need to use a parser that read the external DTD in the doctype. This is a lot of effort; you may prefer to just use the HTML parser if you have HTML-compatible XHTML with entity references.

于 2009-09-09T14:15:48.660 に答える