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:
<cfset var x = arguments.httpRequest />
<cfset cont = xmlparse(x) />
<cfset var body = xmlsearch(cont, "//SOAP-ENV:Body")[1] />
<cfset var args = body.xmlchildren[1].xmlchildren />
<cfset xmlElements = {} />
<cfset xmlElements["#args[1].xmlName#"] = "#args[1].xmlText#" />
so i can get each element of args if it isn't a complexType. To access the children of the complex elements i used this way:
<cfset var children = "" />
<cfset children = args[3].xmlchildren />
<cfset children = args[1].xmlchildren />
XML for the third element looks like this:
<Element>
<item>
<child1>XP_RA_10</child1>
<child2>RA-EXPRESS-KATALOG</Wmvtx>
</item>
</Element>
But i would like to create a method which does check if there are any xmlchildren or not. I tried to do it that way...
<cfif ArrayIsDefined(i.xmlchildren, 1)>
<cfset children = args[i].xmlchildren />
<cfif ArrayIsDefined(children[1].xmlchildren, 1)>
<!--- if more xmlchildren exist --->
<cfelse>
<!if one xmlchildren exist --->
</cfif>
<cfelse>
<!--- if xmlchidren doesn't exist --->
</cfif>
...but i don't get access to the elements to insert them into the struct i created bevor. Always getting an error that the struct is undefined....
Is it the right way to check if there are any child-elements?