xml - Looping over XmlChildern with Coldfusion -


i have xml document:

<book>   <content>     <chapter2>      </chapter2>     <chapter3>      </chapter3>   </content> </book>  <cffile action="read" file="file.xml" variable="myxml"> <cfset mydoc = xmlparse(myxml)> <cfset booknodes = xmlsearch(mydoc,'book/content') >  <cfloop from="1" to="#arraylen(booknodes)#" index="i" step="1">       <cfset bookxml = xmlparse(booknodes[i])> #bookxml.content.xmlchildren[i].xmlname# </cfloop> 

in trying make sure had code correct trying print out xmlname element. chapter2 , chapter3.

the loop prints chapter2 , when print arraylen of booknodes says 1 when dump variable booknodes chapter 3 node present of childern.

the loop seems stop after one.

am missing something?

you referencing wrong thing , don't need convoluted xmlsearch, etc... here:

<cfset booknodes = myxml.book.content> <cfloop from="1" to="#arraylen(booknodes.xmlchildren)#" index="i" step="1">   <cfoutput>#booknodes.xmlchildren[i].xmlname#</cfoutput> </cfloop> 

Comments

Popular posts from this blog

how to proxy from https to http with lighttpd -

android - Automated my builds -

python - Flask migration error -