# Recursively iterate through XML nodes

**URL:** https://www.finalbuilder.com/forums/t/recursively-iterate-through-xml-nodes/97
**Category:** Discussion
**Created:** [May 23, 2006, 12:35pm UTC](https://www.finalbuilder.com/forums/t/recursively-iterate-through-xml-nodes/97 "2006-05-23T12:35:31Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![akash](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/a/a5b964/32.png) [@akash](https://www.finalbuilder.com/forums/u/akash)
#### Post date: [May 23, 2006, 12:35pm UTC](https://www.finalbuilder.com/forums/t/recursively-iterate-through-xml-nodes/97/1 "2006-05-23T12:35:31Z")

</div>

I’m having some difficulty recursively iterating through the nodes in an XML file. The file structure is roughly:  
\<mytag…\>  
\</mytag…\>RootNode  
 MyTag  
 MyTag  
 MyTag  
 MyTag\<mytag…\> \</mytag…\>  
  
I’ve created an “Iterator” action list that takes a RootNode xpath parameter and iterates over the child tags. I’ve also managed to call the “Iterator” action list recursively for each child tag (could not do it directly, but via “Iterator”-\>“Dummy ActionList”-\>“Iterator”). So far, so good!   
  
However, what happens when I run the project is that it iterates down the path /RootTag/MyTag[1]/MyTag, but then doesn’t continue to /RootTag/MyTag[2]/MyTag. It seems like the RootNode parameter gets shared between all the recursive calls to “Iterator”, so deeper recursive calls mangle the value that should be used for shallower calls.  
  
Hope that made some sense! Am I trying to do something that FB can’t handle, or is my approach fundamentally flawed?  
  
Thanks  
Akash  
  
Edit : Cleaned up the tag-escaping mess (I think!) - Angus

---

<div class="post-metadata">

### Author: ![tate](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/t/e19b73/32.png) [@tate](https://www.finalbuilder.com/forums/u/tate)
#### Post date: [May 23, 2006, 3:50am UTC](https://www.finalbuilder.com/forums/t/recursively-iterate-through-xml-nodes/97/2 "2006-05-23T03:50:49Z")

</div>

too late for me to understand all that (it's 11:50pm).... but have you tried specifying an xpath like:  
//mynode  
  
this means that it will find any regarless of location in the xml.  
  
let me know if this solution will work before I start scratching my head over that recursive stuff ;)  
  
.t8

---

<div class="post-metadata">

### Author: ![akash](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/a/a5b964/32.png) [@akash](https://www.finalbuilder.com/forums/u/akash)
#### Post date: [May 23, 2006, 4:04am UTC](https://www.finalbuilder.com/forums/t/recursively-iterate-through-xml-nodes/97/3 "2006-05-23T04:04:34Z")

</div>

Thanks Tate, I think that approach will do what I need. However, just in case I need to look at recursive solutions again, are there any known limitations with using recursive techniques in Finalbuilder?

---

<div class="post-metadata">

### Author: ![tate](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/t/e19b73/32.png) [@tate](https://www.finalbuilder.com/forums/u/tate)
#### Post date: [May 24, 2006, 2:41am UTC](https://www.finalbuilder.com/forums/t/recursively-iterate-through-xml-nodes/97/4 "2006-05-24T02:41:45Z")

</div>

Recursion is supported, but maybe not for the iterators. I’ll ask Angus to reply to this later in the week because he did some work on this type of thing.  
  
.t8

---

<div class="post-metadata">

### Author: ![angus](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/a/b3f665/32.png) [@angus](https://www.finalbuilder.com/forums/u/angus)
#### Post date: [May 29, 2006, 3:05am UTC](https://www.finalbuilder.com/forums/t/recursively-iterate-through-xml-nodes/97/5 "2006-05-29T03:05:42Z")

</div>

Hi Akash,  
  
I cleaned up the problems you had posting the tag values (sorry about that.)  
  
Your recursing problem may be a bug in the Action List parameter namespaces (it may not be pushing new RootNode parameters onto the “stack” with each resursive call.) Should work, however. Rather than us trying to recreate it here, would it be possible for you to please send us the project file and the XML file, and we’ll check it out? Send them to [support@finalbuilder.com](mailto:support@finalbuilder.com).  
  
However, Tate’s suggestion about //mynode is probably the easiest option for you. You can also do something like /RootNode/Child///MyTag, which will select all MyTag’s under /RootNode/Child, no matter how deep they may be hiding.  
  
Hth.
