Isn't attributes quicker because flash has to create an object for each
<node> in the XML?  On my projects, attributes are much, much faster to
parse large file sizes with.  Also, XPATH works faster on
attributes(IMO)!

Also, another tip that you may have already figured out, if you can
control the names of the attributes, then have Flash just loop through
the attributes like the code below to parse out all the values.  This is
very fast to code and to parse, but another benefit is if you add
additional attributes, you don't have to remap those.  They will be
brought in automatically!  
 
var parsedData:Array = new Array();
for(i = 0; i < myXML_array.length; i++){
   var newObj:Object = new Object();
   for (var attr in myXML_array[i].attributes){
        newObj[attr] = myXML_array[i].attributes;
   }
   parsedData.push(newObj);
}

Doug Coning 
Senior Web Development Programmer
FORUM Solutions, LLC
 
> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:flashcoders-
> [EMAIL PROTECTED] On Behalf Of Robert Chyko
> Sent: Monday, June 05, 2006 10:57 AM
> To: Flashcoders mailing list
> Subject: RE: [Flashcoders] XML Parsing
> 
> I believe it used to be, but anymore the difference is negligible.
> 
> 
> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On Behalf Of Ash
> Warren
> Sent: Monday, June 05, 2006 10:56 AM
> To: 'Flashcoders mailing list'
> Subject: RE: [Flashcoders] XML Parsing
> 
> 
> I have heard also (have not tested myself) that parsing attributes is
> much
> quicker as well.
> 
> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On Behalf Of Ron
> Wheeler
> Sent: Monday, June 05, 2006 9:07 AM
> To: Flashcoders mailing list
> Subject: Re: [Flashcoders] XML Parsing
> 
> If it was up to me, I would redo the XML to be a bit more concise and
> more "standard".
> <layers>
>     <layer name="LayerOne">
>         <assets
>             <asset width=20 height=10 xPos=50 yPos=30
> name="somename0.bmp" />
>             <asset width=20 height=10 xPos=50 yPos=30
> name="somename1.bmp"/>
>        </assets>
>     </layer>
>     <layer name="LayerTwo">
>         <assets
>             <asset width=20 height=10 xPos=50 yPos=30
> name="somename2.bmp" />
>        </assets>
>     </layer>
> </layers>
> 
> This will parse better. It is probably easier to create.
> 
> You can parse this into a Layers Object which is a collection (array)
of
> 
> Layer objects.
> The Layer Object has a name (LayerOne) and a list of Asset Objects as
> propertie.s
> The Asset Object has properties which correspond to the XML
> attributes(width, height, etc.).
> 
> The total layers is redundant since it is only the length of the
Layers
> Object array of Layers. function getLayerCount(){return
> layersList.length;}
> 
> 
> If you are stuck with your existing XMl, you can still use the same
> object structure once you have parsed it but will have a more
> complicated parse since you have these LayerOne, LayerTwo trees which
> will have to be recognized in your parse. With XPath, this will be a
> PITA.
> 
> If you write your own parse, you can probably make some assumptions
> about the tree structure which will avoid having to write a lot of
code
> to deal with LayerOne, etc.
> 
> By dynamic, we mean that you just store the whole XML string and parse
> it each time you want some information.
> If you can not fix your XML structure, dynamic parsing will likely be
> too expensive and you should parse the XML once into an object
hierarchy
> 
> and work with the objects.
> 
> Ron
> 
> 
> 
> Sajid Saiyed wrote:
> > Hi,
> > I have an XML like this:
> >
> > <root>
> >     <totalLayers>
> >         <number>5</number>
> >     </totalLayers>
> >     <LayerOne>
> >         <asset>
> >          <name>somename0.bmp</name>
> >         <width>20</width>
> >         <height>10</height>
> >         <xPos>50</xPos>
> >         <yPos>30</yPos>
> >         </asset>
> >         <asset>
> >          <name>somename1.bmp</name>
> >         <width>20</width>
> >         <height>10</height>
> >         <xPos>50</xPos>
> >         <yPos>30</yPos>
> >         </asset>
> >     </LayerOne>
> >     <Layertwo>
> >         <asset>
> >          <name>somename2.bmp</name>
> >         <width>20</width>
> >         <height>10</height>
> >         <xPos>50</xPos>
> >         <yPos>30</yPos>
> >         </asset>
> >     </LayerTwo>
> > </root>
> >
> > I want to use XPATH or something similar to create dynamic
> > arrays/string and store values respectivele like this:
> >
> > String:
> > totalLayers = "5";
> >
> > LayerOne and LayerTwo will be a multidimentional array"
> >
> >
>
LayerOne[[asset[name,width,height,xpos,ypos]][asset[name,width,height,xp
> os,y
> pos]]...]
> >
> >
>
LayerTwo[[asset[name,width,height,xpos,ypos]][asset[name,width,height,xp
> os,y
> pos]]...]
> >
> > etc...
> >
> > Any hint or suggestion...?
> > _______________________________________________
> > Flashcoders@chattyfig.figleaf.com
> > To change your subscription options or search the archive:
> > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
> >
> > Brought to you by Fig Leaf Software
> > Premier Authorized Adobe Consulting and Training
> > http://www.figleaf.com
> > http://training.figleaf.com
> >
> >
> _______________________________________________
> Flashcoders@chattyfig.figleaf.com
> To change your subscription options or search the archive:
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
> 
> Brought to you by Fig Leaf Software
> Premier Authorized Adobe Consulting and Training
> http://www.figleaf.com
> http://training.figleaf.com
> 
> _______________________________________________
> Flashcoders@chattyfig.figleaf.com
> To change your subscription options or search the archive:
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
> 
> Brought to you by Fig Leaf Software
> Premier Authorized Adobe Consulting and Training
> http://www.figleaf.com
> http://training.figleaf.com
> _______________________________________________
> Flashcoders@chattyfig.figleaf.com
> To change your subscription options or search the archive:
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
> 
> Brought to you by Fig Leaf Software
> Premier Authorized Adobe Consulting and Training
> http://www.figleaf.com
> http://training.figleaf.com
 
This e-mail and any attachment(s) are intended for the specified recipient(s) 
only and are legally protected.  If you have received this communication in 
error, please "reply to" sender's e-mail address with notification of the error 
and then destroy this message in all electronic and physical forms.
_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

Reply via email to