XML2 - Find the Maximum Depth

  • + 0 comments

    Finally iv found a one liner. Im gona tell my doc im ready to quit Xanax .

    maxdepth = 0
    def depth(elem, level= 0):
        global maxdepth
        maxdepth = max(maxdepth, level + 1) if [depth(e, level + 1) for e in elem] else max(maxdepth, level + 1)