Xml traversal

This is the place for queries that don't fit in any of the other categories.

Xml traversal

Postby bajaj » Fri May 31, 2013 2:24 am

Hi ,
I am trying to visit every element on an xml through recursion
Code: Select all
   t=recur(root)  #Passing the xml root elemnet

def recur(e):
   for ch in e.iter():



I am getting an runtime error: max recursion depth. I am not sure what's going wrong. If I am print the vale of ch is working fine.
Posts: 2
Joined: Wed May 29, 2013 6:41 pm

Re: Xml traversal

Postby Mekire » Fri May 31, 2013 4:53 am

Well assuming your code is doing what you want, you can change the max recursion depth. The default seems to be 1000.

You can change it as follows:
Code: Select all
import sys

New Users, Read This
  • Use code tags when posting code.
  • Include any errors with your post (in code tags).
  • Describe your problem; not your chosen solution.
  • Make examples the minimum length to demonstrate your issue.
User avatar
Posts: 1600
Joined: Thu Feb 07, 2013 11:33 pm
Location: Tucson, Arizona

Return to General Coding Help

Who is online

Users browsing this forum: No registered users and 4 guests