...

n00b question - XML import

eddjc
02-24-2010, 11:27 PM
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()">

<mx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import mx.rpc.events.ResultEvent;


[Bindable]
private var plist:ArrayCollection;

private function resultHandler(event:ResultEvent) :void {

plist = event.result.playlist.tracklist;

}

]]>
</mx:Script>
<mx:HBox paddingBottom="10" paddingTop="10" paddingLeft="10" paddingRight="10" horizontalGap="20">
<mx:Image/>

</mx:HBox>

<mx:HTTPService id="playlist" url="playlist.xml" result="resultHandler(event)"/>

<mx:DataGrid dataProvider="{plist}" width="100%" height="100%" />

</mx:Application>

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>
<info></info>
<annotation></annotation>
<trackList>

<track>
<creator>Tous les matin du monde</creator>
<title>Ossian Ensemble, Late Music Concert Series, 7/11/09</title>
<location>/mp3s/matin.mp3</location>
<image>images/ossia.jpg</image>
<info></info>
<album>Late Music Concert Series 09</album>
</track>
</trackList>
</playlist>


Any help would be greatly appreciated!

Best
Edd

eddjc
02-24-2010, 11:36 PM
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...

Cheers
Edd



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum