Class iterparse
object --+
|
_BaseParser --+
|
iterparse
Incremental parser. Parses XML into a tree and generates tuples
(event, element) in a SAX-like fashion. ``event`` is any of 'start',
'end', 'start-ns', 'end-ns'.
For 'start' and 'end', ``element`` is the Element that the parser just
found opening or closing. For 'start-ns', it is a tuple (prefix, URI) of
a new namespace declaration. For 'end-ns', it is simply None. Note that
all start and end events are guaranteed to be properly nested.
The keyword argument ``events`` specifies a sequence of event type
names that should be generated. By default, only 'end' events will be
generated.
The additional ``tag`` argument restricts the 'start' and 'end' events
to those elements that match the given tag. By default, events are
generated for all elements. Note that the 'start-ns' and 'end-ns' events
are not impacted by this restriction.
The other keyword arguments in the constructor are mainly based on the
libxml2 parser configuration. A DTD will also be loaded if validation or
attribute default values are requested.
Available boolean keyword arguments: * attribute_defaults - read
default attributes from DTD * dtd_validation - validate (if DTD is
available) * load_dtd - use DTD for parsing * no_network
- prevent network access for related files * remove_blank_text - discard
blank text nodes * remove_comments - discard comments * remove_pis
- discard processing instructions
Other keyword arguments: * encoding - override the document
encoding
|
__init__(...)
x.__init__(...) initializes x; see x.__class__.__doc__ for
signature |
|
|
|
|
|
__new__(T,
S,
...)
Returns:
a new object with type S, a subtype of T |
|
|
|
|
|
copy(...)
Create a new parser with the same configuration. |
|
|
|
next(x)
Returns:
the next value, or raise StopIteration |
|
|
Inherited from _BaseParser :
makeelement ,
setElementClassLookup ,
set_element_class_lookup
Inherited from object :
__delattr__ ,
__getattribute__ ,
__hash__ ,
__reduce__ ,
__reduce_ex__ ,
__repr__ ,
__setattr__ ,
__str__
|
|
error_log
The error log of the last (or current) parser run.
|
|
root
|
Inherited from _BaseParser :
resolvers ,
version
Inherited from object :
__class__
|
__init__(...)
(Constructor)
|
|
x.__init__(...) initializes x; see x.__class__.__doc__ for
signature
- Overrides:
_BaseParser.__init__
|
Create a new parser with the same configuration.
- Overrides:
_BaseParser.copy
- (inherited documentation)
|
- Returns:
the next value, or raise StopIteration
|