get_xml_iterator¶
-
astropy.utils.xml.iterparser.get_xml_iterator(source, _debug_python_based_parser=False)[source] [edit on github]¶ Returns an iterator over the elements of an XML file.
The iterator doesn’t ever build a tree, so it is much more memory and time efficient than the alternative in
cElementTree.Parameters: fd : readable file-like object or read function
Returns: parts : iterator
The iterator returns 4-tuples (start, tag, data, pos):
start: when
Trueis a start element event, otherwise an end element event.tag: The name of the element
data: Depends on the value of event:
- if start ==
True, data is a dictionary of attributes - if start ==
False, data is a string containing the text content of the element
- if start ==
pos: Tuple (line, col) indicating the source of the event.