diff options
author | Leonard Richardson <leonard.richardson@canonical.com> | 2011-02-26 20:56:47 -0500 |
---|---|---|
committer | Leonard Richardson <leonard.richardson@canonical.com> | 2011-02-26 20:56:47 -0500 |
commit | ef5770589595e80cbd9690b64504a2166b3558fd (patch) | |
tree | ac9313b90f2fb5b0e93d5c1a4788c5a4ba0b523e /beautifulsoup/builder/_lxml.py | |
parent | 48e0b434806f557e086abdf0393d071663e3770a (diff) |
Emit an XML declaration when appropriate.
Diffstat (limited to 'beautifulsoup/builder/_lxml.py')
-rw-r--r-- | beautifulsoup/builder/_lxml.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/beautifulsoup/builder/_lxml.py b/beautifulsoup/builder/_lxml.py index 4c7a826..23ac485 100644 --- a/beautifulsoup/builder/_lxml.py +++ b/beautifulsoup/builder/_lxml.py @@ -20,6 +20,8 @@ LXML = 'lxml' class LXMLTreeBuilderForXML(TreeBuilder): DEFAULT_PARSER_CLASS = etree.XMLParser + is_xml = True + # Well, it's permissive by XML parser standards. features = [LXML, XML, FAST, PERMISSIVE] @@ -87,10 +89,15 @@ class LXMLTreeBuilderForXML(TreeBuilder): self.soup.handle_data(content) self.soup.endData(Comment) + def test_fragment_to_document(self, fragment): + """See `TreeBuilder`.""" + return u'<?xml version="1.0" encoding="utf-8">\n%s' % fragment + class LXMLTreeBuilder(HTMLTreeBuilder, LXMLTreeBuilderForXML): features = [LXML, HTML, FAST] + is_xml = False @property def default_parser(self): |