Hi all,

I have written a recursive function that isn't displaying information
correctly and I was wondering if anyone else could see what I am doing
wrong.

Here is the code:
<cffunction name="parseXML" returntype="string">
 <cfargument name="xmlChild" required="Yes" type="any">
 <cfargument name="preChars" required="No" type="string" default="">
 
 <cfset var myRetVal = "">
 <cfset var myStructList = "">
 <cfset var theLoop = "">
 <cfset var secLoop = "">
 <cfset preChars = preChars & "&nbsp;&nbsp;">
 
 <cfif isXMLRoot(xmlChild)>
  <cfset myRetVal = xmlChild.xmlName & "<br />">
 <cfelse>
  <cfset myRetVal = preChars & xmlChild.xmlName>
  <cfif xmlChild.xmlText NEQ "">
   <cfset myRetVal = myRetVal & ":&nbsp;" & xmlChild.xmlText>
  </cfif>
  <cfset myRetVal = myRetVal & "<br />">
 </cfif>
 
 <cfif not structIsEmpty(xmlChild.xmlAttributes)>
  <cfset myStructList = structKeyList(xmlChild.xmlAttributes, ",")>
  <cfloop list="#myStructList#" delimiters="," index="theLoop">
   <cfset myRetVal = "&nbsp;&nbsp;" & theLoop & "&nbsp;" &
xmlChild.xmlAttributes["#theLoop#"] & "<br />">
  </cfloop>
 </cfif>
 
 <cfif arrayLen(xmlChild.xmlChildren)>
  <cfloop from="1" to="#arrayLen(xmlChild.xmlChildren)#" index="secLoop">
   <cfset myRetVal = myRetVal & parseXML(xnChild.xmlChildren[secLoop],
preChars)>
  </cfloop>
 </cfif>

 <cfreturn myRetVal>
</cffunction>

Here is the output:
ScanResults
    MachineName: TestMachine
    Domain: TestDomain
    Product:  
      MachineName: TestMachine
      Domain: TestDomain
    Product:  
      MachineName: TestMachine
      Domain: TestDomain
    Product:  
      MachineName: TestMachine
The test is done!

Here is what it looks like if I code it manually with out a function
(knowing exactly what my test xml document looks like, I will have no idea
what the final xml will look like hence the function):
Report Name: ScanResults
  ScanDateTime : Mon Aug 18 11:10:24 2003
  XMLDataVersion : 1.1.1.806
  ScannedBy : EWST70 \ SD1985
  ScannerDetails : 
    Version : HFNetChk(Pro) version 3.86
    DevelopedBy : Shavlik Technologies, LLC
    Website : http://www.shavlik.com
    Information : [EMAIL PROTECTED]
    Phone : (651)-426-6624
  Machine : 
    MachineName : PFP01
    Domain : AITMI
    Product : 
    Product : 
    Product : 
    Product : 
    Product : 
    Product : 


It's probably something simple, I'm just not seeing it this morning.

Thanks,
Steve
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/lists.cfm?link=t:4
Subscription: http://www.houseoffusion.com/lists.cfm?link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

This list and all House of Fusion resources hosted by CFHosting.com. The place for 
dependable ColdFusion Hosting.
http://www.cfhosting.com

Reply via email to