Ok, I was wondering if I could get some help on something I'm trying to 
accomplish.
I'm trying to build a function that takes an array of xmlelements,
whether its from an xmlsearch() - xpath expression, or the -.xmlchildren
and builds an xmldoc object, or an xmlelement object to be used somewhere 
else.


@ - xmlarray (required) array of xml elements
@ - xnmlrootobj, either a predefined xmlroot obj or a string
@ - xmlelemname - either to use as a element to be returned, or as the root 
of the xmldoc

function xx(xmlarray,xmlrootobj,xmlelemname){
                        var flag = 0;
                        var i = 1;
                        var tester = "";
                        //assume if it's not an xmlobj it was sent in as a string so 
we'll build 
one.
                        if(not IsXmlDoc(xmlrootobj))
                                {
                                        flag = 1;
                                        xmlrootobj = xmlnew();
                                        xmlrootobj.xmlelemname = 
xmlelemnew(xmlrootobj,xmlelemname);
                                }
                                else
                                        {
                                                xmlelemname = 
xmlelemnew(xmlrootobj,xmlelemname);
                                        }
                                                for(i=1;i lte arraylen(xmlarray);i=i+1)
                                                        {
                                                                 // ~ if xmlname is on 
the left side of the assignment, cfmx thinks 
I'm using it to set a property even though I'm just referencing its value,
                                                                 // ~ so I'm giving it 
a temp value to carry it through the loop.
                                                                 tester = 
xmlarray[i].xmlname;
                                                                 // ~ create a new 
element
                                                                 tester = 
xmlelemnew(xmlrootobj,tester);
                                                                 // ~ I'm fully aware 
that the XmlNsPrefix has to conform to spec, 
but it seems needless that
                                                                 // ~ I have to check 
if it has a value when the rest of the cfmx 
xml doc types
                                                                 // ~ can just be 
duplicated even if the value is an empty string. 
eg. tester.XmlNsPrefix = xmlarray[i].XmlNsPrefix; or tester.XmlNsPrefix = 
duplicate(xmlarray[i].XmlNsPrefix);
                                                                 // ~ both error out 
if it's an emptry string.
                                                                        
if(len(xmlarray[i].XmlNsPrefix))
                                                                                {
                                                                                
tester.XmlNsPrefix = xmlarray[i].XmlNsPrefix;
                                                                                }
                                                                 tester.xmltext =  
duplicate(xmlarray[i].xmltext);
                                                                 tester.XmlNsURI =  
duplicate(xmlarray[i].XmlNsURI);
                                                                 tester.XmlComment =  
duplicate(xmlarray[i].XmlComment);
                                                                 tester.xmlattributes 
= duplicate(xmlarray[i].xmlattributes);
                        // now here is my delimma, . the xmlchildren array of the 
xmlelement is 
essentially the same thing as the array I'm passing in.
                        // so I want to check if the array itself has any value and if 
so pass it 
back to this function to parse through that array.
                        // which I know isn't the best thing, but with no true other 
way to move 
children of one doc to another, it's pretty much the only way I have.
                                                                if( 
arraylen(xmlarray[i].xmlchildren))
                                                                {
                                                                        
xx(xmlarray[i].xmlchildren,xmlrootobj,tester)
                                                                }
                        // The problem I have comes here.. I can't figure out how to 
append the 
children to it's parent on the fly.
                        // in another words I can't figure out how to put the 
xmlchildren back 
into this function and have it appended to the parent of that function which 
would allow me to build the xml doc/element with all children duplicated 
over.

                                                                
arrayappend(xmlelemname.xmlchildren,tester);
                                                        }//end loop

                                                                 if(flag)
                                                                 {
                                                                        return 
xmlrootobj;
                                                                 }
                                                                 else
                                                                 {
                                                                        return 
xmlelemname;
                                                                 }



        }


        any ideas, ? or something similar  out there?

Robby

_________________________________________________________________
Tired of spam? Get advanced junk mail protection with MSN 8. 
http://join.msn.com/?page=features/junkmail

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: 
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq

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

                                Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
                                

Reply via email to