Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Aug 2008
    Thanked 14 Times in 14 Posts

    n00b question - XML import

    Hi guys,

    Sorry to be a pain - trying to get my head round XML import - I've written as best I can a script that simply imports an XML file onto a datagrid (in very similar fashion to the vid tutorial on Adobe's website) - here is the MXML:

    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" backgroundAlpha="0"
    	initialize = "playlist.send()">
    			import mx.collections.ArrayCollection;
    			import mx.rpc.events.ResultEvent;
    			private var plist:ArrayCollection;
    			private function resultHandler(event:ResultEvent) :void {
    				plist = event.result.playlist.tracklist;
    	<mx:HBox paddingBottom="10" paddingTop="10" paddingLeft="10" paddingRight="10" horizontalGap="20">
    	<mx:HTTPService id="playlist" url="playlist.xml" result="resultHandler(event)"/>
    	<mx:DataGrid dataProvider="{plist}" width="100%" height="100%" />
    for some reason I cannot fathom, when I debug this script with a breakpoint at the end of resultHandler(), although event is fully populated with all the right info, plist remains stubbornly "null". I'm sure I'm missing something, but I've no idea what! Anyone any ideas why plist isn't being assigned?

    Here is a sample of the XML data:

    <playlist version="1" xmlns="http://xspf.org/ns/0/">
    	<title>Edward Caine Pieces</title>
    			<creator>Tous les matin du monde</creator>
    			<title>Ossian Ensemble, Late Music Concert Series, 7/11/09</title>
    			<album>Late Music Concert Series 09</album>
    Any help would be greatly appreciated!

    Last edited by eddjc; 02-24-2010 at 11:28 PM. Reason: mistake in code

  2. #2
    Regular Coder
    Join Date
    Aug 2008
    Thanked 14 Times in 14 Posts
    Hello All,

    Well as usual, astonishingly, I worked out what was wrong within 5 seconds of posting (LOL - 30 mins scratching your head, 2 mins typing up to forum, then 5 seconds to go "Ugh", slap your forehead and then logon to the forums to apologise)

    Basically, I'd not clocked that <trackList></trackList> in my XML was spelt with a capital L. Also my code was slightly wrong - the ArrayCollection was event.result.playlist.trackList.track but that was a fault in my post - that was the array I expected.

    Doh! Thank you for your time reading though if you did! Sorry for the rookie mistake...



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts