diff options
author | Leonard Richardson <leonard.richardson@canonical.com> | 2012-02-28 10:33:15 -0500 |
---|---|---|
committer | Leonard Richardson <leonard.richardson@canonical.com> | 2012-02-28 10:33:15 -0500 |
commit | 6628fc01dc27ecc522eb449fa654185fecdf5f8c (patch) | |
tree | 081cc4e1cd14c95b807fd9a0600ac57f88a14416 /bs4 | |
parent | f503a773d851ca3a0f1b690e8065a445f34acca9 (diff) |
Fixed the generated XML declaration.
Diffstat (limited to 'bs4')
-rw-r--r-- | bs4/__init__.py | 2 | ||||
-rw-r--r-- | bs4/builder/_lxml.py | 2 | ||||
-rw-r--r-- | bs4/testing.py | 6 |
3 files changed, 5 insertions, 5 deletions
diff --git a/bs4/__init__.py b/bs4/__init__.py index cbd0fd6..7a36493 100644 --- a/bs4/__init__.py +++ b/bs4/__init__.py @@ -319,7 +319,7 @@ class BeautifulSoup(Tag): encoding_part = '' if eventual_encoding != None: encoding_part = ' encoding="%s"' % eventual_encoding - prefix = u'<?xml version="1.0"%s>\n' % encoding_part + prefix = u'<?xml version="1.0"%s?>\n' % encoding_part else: prefix = u'' if not pretty_print: diff --git a/bs4/builder/_lxml.py b/bs4/builder/_lxml.py index e5e30d4..39ad396 100644 --- a/bs4/builder/_lxml.py +++ b/bs4/builder/_lxml.py @@ -142,7 +142,7 @@ class LXMLTreeBuilderForXML(TreeBuilder): def test_fragment_to_document(self, fragment): """See `TreeBuilder`.""" - return u'<?xml version="1.0" encoding="utf-8">\n%s' % fragment + return u'<?xml version="1.0" encoding="utf-8"?>\n%s' % fragment class LXMLTreeBuilder(HTMLTreeBuilder, LXMLTreeBuilderForXML): diff --git a/bs4/testing.py b/bs4/testing.py index 49644c3..717e721 100644 --- a/bs4/testing.py +++ b/bs4/testing.py @@ -370,17 +370,17 @@ class XMLTreeBuilderSmokeTest(object): def test_docstring_generated(self): soup = self.soup("<root/>") self.assertEqual( - soup.encode(), b'<?xml version="1.0" encoding="utf-8">\n<root/>') + soup.encode(), b'<?xml version="1.0" encoding="utf-8"?>\n<root/>') def test_docstring_includes_correct_encoding(self): soup = self.soup("<root/>") self.assertEqual( soup.encode("latin1"), - b'<?xml version="1.0" encoding="latin1">\n<root/>') + b'<?xml version="1.0" encoding="latin1"?>\n<root/>') def test_real_xhtml_document(self): """A real XHTML document should come out the same as it went in.""" - markup = b"""<?xml version="1.0" encoding="utf-8"> + markup = b"""<?xml version="1.0" encoding="utf-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"> <html xmlns="http://www.w3.org/1999/xhtml"> <head><title>Hello.</title></head> |