To use Xpath, if you are using the xfactorstudios classes (I don't know
much about the built in Xpath features of Flash), you can access a
string like:
String(XPath.selectNodes(theXMLobject, thePathToTheNode)
Or for a number:
parseInt(XPath.selectNodes(theXMLobject, thePathToTheNode)[0]);
For the length of a node array:
XPath.selectNodes(theXMLobject, thePathToTheNodeArray).length;
(NOTE: keep in mind these Xpath classes start numbering at 1, not 0 like
in Actionscript)
Then, instead of multidimensional arrays like that, I would use
something more logically organized and easier to traverse, like an array
of Objects:
Layers = [{assets:[{name:"somename0.bmp", width:20, xPos:50, yPos:10},
{name:"somename1.bmp", width:20, xPos:100, yPos:15},
{name:"somename2.bmp", width:40, xPos:160,
yPos:20}]},
{assets:[{name:"somename3.bmp", width:20, xPos:50,
yPos:55},
{name:"somename4.bmp", width:20, xPos:100, yPos:60}
{name:"somename5.bmp", width:40, xPos:160, yPos:65}]}]; //etc.
Usage examples:
//to get the number of layers:
totalLayers = Layers.length
trace(totalLayers);
//To access layer 1's first asset name:
trace(Layers[0].assets[1].name)
//To access layer 2's third asset yPos:
trace(Layers[1].assets[2].yPos);
Jason Merrill
Bank of America
Learning Technology Solutions
>>-----Original Message-----
>>From: [EMAIL PROTECTED] [mailto:flashcoders-
>>[EMAIL PROTECTED] On Behalf Of Sajid Saiyed
>>Sent: Monday, June 05, 2006 4:18 AM
>>To: Flashcoders mailing list
>>Subject: [Flashcoders] XML Parsing
>>
>>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,
xpos,yp
>>os]]...]
>>LayerTwo[[asset[name,width,height,xpos,ypos]][asset[name,width,height,
xpos,yp
>>os]]...]
>>etc...
>>
>>Any hint or suggestion...?
>>_______________________________________________
>>[email protected]
>>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
_______________________________________________
[email protected]
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