source: exist/trunk/python/elementtree-1.3a6-20070220-badc/unittests/test_simplexmlwriter.py @ 3578

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/exist/trunk/python/elementtree-1.3a6-20070220-badc/unittests/test_simplexmlwriter.py@3578
Revision 3578, 1.1 KB checked in by pjkersha, 11 years ago (diff)

Latest releases from Fredrik Lundh. 10 March release has exclusive C14N support with namespace prefixes.

Line 
1# $Id: test_simplexmlwriter.py 3298 2007-09-13 14:38:02Z fredrik $
2# -*- coding: iso-8859-1 -*-
3
4from elementtree import SimpleXMLWriter
5from StringIO import StringIO
6
7def xmlwriter():
8    r"""
9    >>> file = StringIO()
10    >>> w = SimpleXMLWriter.XMLWriter(file)
11    >>> html = w.start("html")
12    >>> x = w.start("head")
13    >>> w.element("title", "my document")
14    >>> w.data("\n")
15    >>> w.element("meta", name="hello", value="goodbye")
16    >>> w.data("\n")
17    >>> w.end()
18    >>> x = w.start("body")
19    >>> w.element("h1", "this is a heading")
20    >>> w.data("\n")
21    >>> w.element("p", u"this is a paragraph")
22    >>> w.data("\n")
23    >>> w.element("p", u"reserved characters: <&>")
24    >>> w.data("\n")
25    >>> w.element("p", u"detta är också ett stycke")
26    >>> w.data("\n")
27    >>> w.close(html)
28    >>> print file.getvalue()
29    <html><head><title>my document</title>
30    <meta name="hello" value="goodbye" />
31    </head><body><h1>this is a heading</h1>
32    <p>this is a paragraph</p>
33    <p>reserved characters: &lt;&amp;&gt;</p>
34    <p>detta &#228;r ocks&#229; ett stycke</p>
35    </body></html>
36    """
Note: See TracBrowser for help on using the repository browser.