MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / XMLID

Function XMLID

tools/python-3.11.9-amd64/Lib/xml/etree/ElementTree.py:1354–1373  ·  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

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