detect xml encoding
This commit is contained in:
parent
217849b4a2
commit
dec5789e37
1 changed files with 6 additions and 0 deletions
|
|
@ -415,6 +415,12 @@ class XMLPage(Page):
|
||||||
XML Page.
|
XML Page.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
def detect_encoding(self):
|
||||||
|
import re
|
||||||
|
m = re.search('<\?xml version="1.0" encoding="(.*)"\?>', self.data)
|
||||||
|
if m:
|
||||||
|
return m.group(1)
|
||||||
|
|
||||||
def build_doc(self, content):
|
def build_doc(self, content):
|
||||||
import lxml.etree as etree
|
import lxml.etree as etree
|
||||||
parser = etree.XMLParser(encoding=self.encoding)
|
parser = etree.XMLParser(encoding=self.encoding)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue