source: exist/branches/proglue_production_rev4605_xquery4884/python/elementtree-1.3b1-20080615-badc/unittests/test_iterparse.py @ 4886

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/exist/branches/proglue_production_rev4605_xquery4884/python/elementtree-1.3b1-20080615-badc/unittests/test_iterparse.py@4886
Revision 4886, 1.8 KB checked in by sdonegan, 10 years ago (diff)

Creating operational branch for ndgUtils as used on proglue

Line 
1# $Id: test_iterparse.py 3298 2007-09-13 14:38:02Z fredrik $
2
3from support import *
4
5def iterparse():
6    """
7    Test iterparse interface.
8
9    >>> iterparse = ET.iterparse
10
11    >>> context = iterparse("samples/simple.xml")
12    >>> for action, elem in context:
13    ...   print action, elem.tag
14    end element
15    end element
16    end empty-element
17    end root
18    >>> context.root.tag
19    'root'
20
21    >>> context = iterparse("samples/simple-ns.xml")
22    >>> for action, elem in context:
23    ...   print action, elem.tag
24    end {namespace}element
25    end {namespace}element
26    end {namespace}empty-element
27    end {namespace}root
28
29    >>> events = ()
30    >>> context = iterparse("samples/simple.xml", events)
31    >>> for action, elem in context:
32    ...   print action, elem.tag
33
34    >>> events = ()
35    >>> context = iterparse("samples/simple.xml", events=events)
36    >>> for action, elem in context:
37    ...   print action, elem.tag
38
39    >>> events = ("start", "end")
40    >>> context = iterparse("samples/simple.xml", events)
41    >>> for action, elem in context:
42    ...   print action, elem.tag
43    start root
44    start element
45    end element
46    start element
47    end element
48    start empty-element
49    end empty-element
50    end root
51
52    >>> events = ("start", "end", "start-ns", "end-ns")
53    >>> context = iterparse("samples/simple-ns.xml", events)
54    >>> for action, elem in context:
55    ...   if action in ("start", "end"):
56    ...     print action, elem.tag
57    ...   else:
58    ...     print action, elem
59    start-ns ('', 'namespace')
60    start {namespace}root
61    start {namespace}element
62    end {namespace}element
63    start {namespace}element
64    end {namespace}element
65    start {namespace}empty-element
66    end {namespace}empty-element
67    end {namespace}root
68    end-ns None
69
70    """
Note: See TracBrowser for help on using the repository browser.