Page MenuHomeSoftware Heritage
Paste P1252

xmltodict xmlns
ActivePublic

Authored by vlorentz on Jan 10 2022, 2:25 PM.
>>> s = '<entry xmlns:testns="https://example.org"> <testns:foo> <testns:bar url="http://example.org/1" /> <testns:bar url="http://example.org/2" /></testns:foo> </entry>'
>>> pprint(xmltodict.parse(s, process_namespaces=True, dict_constructor=dict))
{'entry': {'https://example.org:foo': {'https://example.org:bar': [{'@url': 'http://example.org/1',
'@xmlns': OrderedDict([('testns',
'https://example.org')])},
{'@url': 'http://example.org/2'}]}}}

Event Timeline

vlorentz edited the content of this paste. (Show Details)