0
loading XML node into an Array
Explorer
,
/t5/animate-discussions/loading-xml-node-into-an-array/td-p/152231
Oct 30, 2008
Oct 30, 2008
Copy link to clipboard
Copied
greetings all,
i'm trying to load a node from an xml page into an array.
i can get the xml to load but i can't get the node into the
_streamList.push( { path:"PLAYLIST.SRC_NODE", bitrate:800 } );
i can get the file to load with a direct path "no xml"
_streamList.push( { path:"mp4:videofile.mp4", bitrate:800 } );
any help or advice would be a great help.
this is what i've got so far
thank for your help
cheers
i'm trying to load a node from an xml page into an array.
i can get the xml to load but i can't get the node into the
_streamList.push( { path:"PLAYLIST.SRC_NODE", bitrate:800 } );
i can get the file to load with a direct path "no xml"
_streamList.push( { path:"mp4:videofile.mp4", bitrate:800 } );
any help or advice would be a great help.
this is what i've got so far
thank for your help
cheers
TOPICS
ActionScript
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Community Expert
,
/t5/animate-discussions/loading-xml-node-into-an-array/m-p/152232#M5155
Nov 01, 2008
Nov 01, 2008
Copy link to clipboard
Copied
Try declaring an XMLList varaible at the top:
public var xmlList:XMLList;
Then set that to the xml's children:
xmlList=loadPlaylist.children();
Now you have an array of elements in the xml's children
trace (xmlList[1]);//returns mp4:Trailer_HD.mp4
If there were more than one child in your xml then
trace (xmlList[1].children()[1]);//returns the second element of the second child
public var xmlList:XMLList;
Then set that to the xml's children:
xmlList=loadPlaylist.children();
Now you have an array of elements in the xml's children
trace (xmlList[1]);//returns mp4:Trailer_HD.mp4
If there were more than one child in your xml then
trace (xmlList[1].children()[1]);//returns the second element of the second child
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Community Expert
,
LATEST
/t5/animate-discussions/loading-xml-node-into-an-array/m-p/152233#M5156
Nov 01, 2008
Nov 01, 2008
Copy link to clipboard
Copied
You might also consider using XML attributes, which might be
a simpler approach than pushing an object into an array.
So if your XML looked something like this with a single child:
<playlist>
<song desc="title 1" src="mp4:Trailer_HD1.mp4" thumb="thumbs/tumb1.jpg" brate="800"/>
<song desc="title 2" src="mp4:Trailer_HD2.mp4" thumb="thumbs/tumb2.jpg" brate="800"/>
<song desc="title 3" src="mp4:Trailer_HD3.mp4" thumb="thumbs/tumb3.jpg" brate="800"/>
<song desc="title 4" src="mp4:Trailer_HD4.mp4" thumb="thumbs/tumb4.jpg" brate="800"/>
</playlist>
Now you can treat the XMLList itself as an array of objects. So:
trace (xmlList[0].@desc);//returns title1
trace (xmlList[2].@src);//returns mp4:Trailer_HD3.mp4
etc.
So if your XML looked something like this with a single child:
<playlist>
<song desc="title 1" src="mp4:Trailer_HD1.mp4" thumb="thumbs/tumb1.jpg" brate="800"/>
<song desc="title 2" src="mp4:Trailer_HD2.mp4" thumb="thumbs/tumb2.jpg" brate="800"/>
<song desc="title 3" src="mp4:Trailer_HD3.mp4" thumb="thumbs/tumb3.jpg" brate="800"/>
<song desc="title 4" src="mp4:Trailer_HD4.mp4" thumb="thumbs/tumb4.jpg" brate="800"/>
</playlist>
Now you can treat the XMLList itself as an array of objects. So:
trace (xmlList[0].@desc);//returns title1
trace (xmlList[2].@src);//returns mp4:Trailer_HD3.mp4
etc.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more

