I have a xml file that I need to pull a specific element and it's children.  I'm 
passing in the element name upon which I need to filter out it's children.  I've 
figured it out using a cfloop to find the element then another cfloop to pull its 
children.  Is there an easier way to do this?

Here's xml snipet:
<?xml version="1.0" encoding="iso-8859-1"?>
<ElementTemplates>
   <TextBox>
      <elementType>TextBox</elementType>
      <elementName/>
      <elementLabel/>
      <elementLabelClass/>
      <elementClass/>
      <elementPosition/>
      <elementSize/>
      <elementMaxLength/>
      <DefaultValue/>
      <xslMember/>
      <editLevel/>
      <ynIsRequired/>
   </TextBox>
   <Memo>
      <elementType>Memo</elementType>
      <elementName/>
      <elementLabel/>
      <elementLabelClass/>
      <elementClass/>
      <elementPosition/>
      <elementCols/>
      <elementRows/>
      <DefaultValue/>
      <xslMember/>
      <editLevel/>
      <ynIsRequired/>
   </Memo>
</ElementTemplates>

I' want to pull TextBox element and there children.  Here's how I'm doing it after 
I've created an object representing the XML chunk:

<cfloop collection="#oElementTemplates.selectNodes("//ElementTemplates/TextBox")#" 
item="oFormElement">
         <cfscript>
                oElementChildNodes = oFormElement.childNodes;
                WriteOutput("oFormElements: " & oFormElement.text & "<br>");
                WriteOutput("oElementChildNodes: " & oElementChildNodes.length & 
"<br>");
         </cfscript>
        
        <cfloop collection="#oElementChildNodes#" item="oElementNode">
                 <cfscript>
                        WriteOutput("oElementNode: " & oElementNode.nodeName & "<br>");
                 </cfscript>            
        </cfloop>
</cfloop>

Thanks - Tom

-----------------------+
cf-xml mailing list
list: [EMAIL PROTECTED]
admin: [EMAIL PROTECTED]
home: http://torchbox.com/xml

Reply via email to