diff options
author | Leonard Richardson <leonard.richardson@canonical.com> | 2011-02-26 20:57:51 -0500 |
---|---|---|
committer | Leonard Richardson <leonard.richardson@canonical.com> | 2011-02-26 20:57:51 -0500 |
commit | 1f4733fd1215411752c4d793d93edbc007fece12 (patch) | |
tree | ac9313b90f2fb5b0e93d5c1a4788c5a4ba0b523e /beautifulsoup/builder/_lxml.py | |
parent | 7db58f67d60bf2675613e38d2d8daeeadc5522db (diff) | |
parent | ef5770589595e80cbd9690b64504a2166b3558fd (diff) |
Emit an XML declaration when appropriate. I'm not totally happy with this, but it's good enough for now.
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): |