# Cycle through all (unknown node structure) xml nodes

**URL:** <https://forum.kirupa.com/t/cycle-through-all-unknown-node-structure-xml-nodes/328679>\
**Category:** flash\
**Created:** [June 5, 2012, 2:09pm UTC](https://forum.kirupa.com/t/cycle-through-all-unknown-node-structure-xml-nodes/328679 "2012-06-05T14:09:15Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Esseti](https://avatars.discourse-cdn.com/v4/letter/e/bb73d2/32.png) [@Esseti](https://forum.kirupa.com/u/Esseti)\
**Post date:** [June 5, 2012, 2:09pm UTC](https://forum.kirupa.com/t/cycle-through-all-unknown-node-structure-xml-nodes/328679/1 "2012-06-05T14:09:15Z")

</div>

How should I format a for loop, or while conditional, to cycle through all of the nodes, node levels in a unknown XML?

For instance, if I load an XML:

```auto

<root>
	<word>
		<word>
			<word>
				<image src="some address" />
			</word>
		</word>
			<word></word>
		<word>
		</word>
		<word>
		</word>
	</word>
</root>

```

There are 3 levels, not couting root. I could write a triple for loop, but that would only work in a 3 level xml. How to write a loop that would cycle through even XX-levels of nesting?
