MCPcopy Index your code
hub / github.com/python/cpython / XMLID

Function XMLID

Lib/xml/etree/ElementTree.py:1360–1379  ·  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

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

Used in the wild real call sites across dependent graphs

searching dependent graphs…