MCPcopy Index your code
hub / github.com/RustPython/RustPython / XMLID

Function XMLID

Lib/xml/etree/ElementTree.py:1356–1375  ·  view source on GitHub ↗

Parse XML document from string constant for its IDs. *text* is a string containing XML data, *parser* is an optional parser instance, defaulting to the standard XMLParser. Returns an (Element, dict) tuple, in which the dict maps element id:s to elements.

(text, parser=None)

Source from the content-addressed store, hash-verified

1354
1355
1356def XMLID(text, parser=None):
1357 """Parse XML document from string constant for its IDs.
1358
1359 *text* is a string containing XML data, *parser* is an
1360 optional parser instance, defaulting to the standard XMLParser.
1361
1362 Returns an (Element, dict) tuple, in which the
1363 dict maps element id:s to elements.
1364
1365 """
1366 if not parser:
1367 parser = XMLParser(target=TreeBuilder())
1368 parser.feed(text)
1369 tree = parser.close()
1370 ids = {}
1371 for elem in tree.iter():
1372 id = elem.get("id")
1373 if id:
1374 ids[id] = elem
1375 return tree, ids
1376
1377# Parse XML document from string constant. Alias for XML().
1378fromstring = XML

Callers

nothing calls this directly

Calls 6

feedMethod · 0.95
closeMethod · 0.95
XMLParserClass · 0.85
TreeBuilderClass · 0.85
iterMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected