I am looking for a way to loop through an XML-Body and pass each xml element into a struct. i got access to the xml body in this way:
unless you know the structure of the XML object ahead of time you will have to test each child object and traverse down the nodes till you know you have a simple object. To help there are the "is" functions as in:
isObject(var);
isStruct(var);
isArray(var);
isSimpleValue(variable);
Once you know you have an array (for example) you loop through it's index by length as in:
<Cfif isArray(children)>
<cfloop form="1" to="#arraylen(children)#" index="i">
<cfset thisNode = children[i]/>
<cfif isStruct(thisNode)?
.... do something with the structkeylist.
</cfif>
<Cfif isArray(thisNode)>
.... more looping...
</cfif>
</cfloop>
</cfif>
This can be pretty daunting for really complex objects. I'm curious as to why you would do it? XML is designed to be "non-flat" - is there a specific requirement to flatten it?
Is this what you were looking for? XmlToStruct on RIAForge