Created
November 5, 2020 13:36
-
-
Save HotcockMiami/d69a11e0b600b088030023d8ea172721 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import xmltodict | |
xml = """ | |
<feed xml:lang='en'> | |
<title>NPBFX</title> | |
<subtitle lang='en'>Programming challenges | |
</subtitle> | |
<link rel='alternate' type='text/html' href='http://npbfx.com/' /> | |
<updated>2020-10-28T12:00:00</updated> | |
</feed> | |
""" | |
xml_dict = xmltodict.parse(xml, xml_attribs = False) | |
print (xml_dict) | |
def depth(d): | |
if isinstance(d, dict): | |
return 1 + (max(map(depth, d.values())) if d else 0) | |
return 0 | |
print (depth(xml_dict)-1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment