Recursively iterate through XML nodes

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


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

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?


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

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.

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.