# \[FMX\] Recursive Parser

**URL:** <https://forum.kirupa.com/t/fmx-recursive-parser/135302>\
**Category:** Uncategorized\
**Created:** [January 26, 2005, 10:50am UTC](https://forum.kirupa.com/t/fmx-recursive-parser/135302 "2005-01-26T10:50:30Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![fideldonson](https://avatars.discourse-cdn.com/v4/letter/f/73ab20/32.png) [@fideldonson](https://forum.kirupa.com/u/fideldonson)\
**Post date:** [January 26, 2005, 10:50am UTC](https://forum.kirupa.com/t/fmx-recursive-parser/135302/1 "2005-01-26T10:50:30Z")

</div>

In my editor i’ve got a dragable menu - where menu items can be dragged up and down and can also be placed as sub menu items. I want to save the structure of this menu in xml. Remember the menu items can contain menu items that contain menu items and so on - forever.

How do i go about creating the xml that reflects this structure - as far as i understand i have to make some kind of recursive function that places each menu item node in the right place in the xml-object. But I can’t get my head around it.

The part that i really can’t figure out is how to place the xml-node in the correct place in the xml-tree and do it dynamically.

Say i have a menu item with a menu item with a menu item. When i have parsed the third level menu item into an xml-node how do i place that node as a child of the second level node?

And even worse how would i go about placing a new second level menu item after the third level menu item?

Any helpful code-snippets, code-outlines or tutorials would be very greatly appreciated.

Thank you all very much for the anticipated solution to my problems.
