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

Reply via email to