Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

loading XML node into an Array

Explorer ,
Oct 30, 2008 Oct 30, 2008
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
TOPICS
ActionScript
389
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 01, 2008 Nov 01, 2008
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




Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 01, 2008 Nov 01, 2008
LATEST
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.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines