from test import test_support
+from xmlcore.etree import ElementTree as ET
+
SAMPLE_XML = """
<body>
<tag>text</tag>
"""
Test element tree interface.
- >>> from xmlcore.etree import ElementTree as ET
-
>>> element = ET.Element("tag", key="value")
>>> tree = ET.ElementTree(element)
"""
Test find methods (including xpath syntax).
- >>> from xmlcore.etree import ElementTree as ET
-
>>> elem = ET.XML(SAMPLE_XML)
>>> elem.find("tag").tag
'tag'
def parseliteral():
r"""
- >>> from xmlcore.etree import ElementTree as ET
-
>>> element = ET.XML("<html><body>text</body></html>")
>>> ET.ElementTree(element).write(sys.stdout)
<html><body>text</body></html>
'body'
"""
+def check_encoding(encoding):
+ """
+ >>> check_encoding("ascii")
+ >>> check_encoding("us-ascii")
+ >>> check_encoding("iso-8859-1")
+ >>> check_encoding("iso-8859-15")
+ >>> check_encoding("cp437")
+ >>> check_encoding("mac-roman")
+ """
+ ET.XML(
+ "<?xml version='1.0' encoding='%s'?><xml />" % encoding
+ )
+
#
# xinclude tests (samples from appendix C of the xinclude specification)
except KeyError:
raise IOError("resource not found")
if parse == "xml":
- from xmlcore.etree.ElementTree import XML
- return XML(data)
+ return ET.XML(data)
return data
def xinclude():
r"""
Basic inclusion example (XInclude C.1)
- >>> from xmlcore.etree import ElementTree as ET
>>> from xmlcore.etree import ElementInclude
>>> document = xinclude_loader("C1.xml")
from test import test_support
+from xmlcore.etree import cElementTree as ET
+
SAMPLE_XML = """
<body>
<tag>text</tag>
"""
Test element tree interface.
- >>> from xmlcore.etree import cElementTree as ET
-
>>> element = ET.Element("tag", key="value")
>>> tree = ET.ElementTree(element)
"""
Test find methods (including xpath syntax).
- >>> from xmlcore.etree import cElementTree as ET
-
>>> elem = ET.XML(SAMPLE_XML)
>>> elem.find("tag").tag
'tag'
def parseliteral():
r"""
- >>> from xmlcore.etree import cElementTree as ET
-
>>> element = ET.XML("<html><body>text</body></html>")
>>> ET.ElementTree(element).write(sys.stdout)
<html><body>text</body></html>
'body'
"""
+def check_encoding(encoding):
+ """
+ >>> check_encoding("ascii")
+ >>> check_encoding("us-ascii")
+ >>> check_encoding("iso-8859-1")
+ >>> check_encoding("iso-8859-15")
+ >>> check_encoding("cp437")
+ >>> check_encoding("mac-roman")
+ """
+ ET.XML(
+ "<?xml version='1.0' encoding='%s'?><xml />" % encoding
+ )
+
def test_main():
from test import test_xml_etree_c
test_support.run_doctest(test_xml_etree_c, verbosity=True)