Sam,

 

There are a few things I would change here. Lets back up a bit:

 

<?xml version="1.0" encoding="utf-8"?>

<mx:Application

            xmlns:mx="http://www.adobe.com/2006/mxml"

            creationComplete="getXML.send()"

            layout="absolute">

           

            <mx:HTTPService id="getXML" url="" resultFormat="e4x"/>

           

            <mx:List width="100%" dataProvider="{getXML.lastResult.data.row}" labelField="@name"/>

           

</mx:Application>

 

Here is a simple example that loads data from an XML file called data.xml. I loaded the XML file with the following XML:

 

<xport>

<data>

<row name="1"/>

<row name="2"/>

<row name="3"/>

<row name="4"/>

<row name="5"/>

<row name="6"/>

<row name="7"/>

<row name="8"/>

<row name="1"/>

</data>

</xport>

 

So first off, I changed the resultFormat of the HTTPService tag to ‘e4x’ which is the default XML format in Flex 2/AS3. In the example I set-up a basic dataprovider specifying “getXML.lastResult.data.row” as the binding. In E4X the root tag is ignored and paths begin within the root tag hence the use of ‘data’. Additionally I mapped the labelField property to the attribute name within item in the dataprovider. The list will lookup the name attribute as data is set in the List row.

 

Ideally this will get the XML data exchange working. Then formatting the results into a AreaChart will follow.

 

Regards,

 

Ted Patrick

Flex Evangelist

Adobe Systems Incorporated

 

 

 

 

 

 


From: [email protected] [mailto:[email protected]] On Behalf Of Sam
Sent: Saturday, October 07, 2006 9:26 PM
To: [email protected]
Subject: [flexcoders] XML as a dataprovider

 

Hi,
I'm trying to use XML as a dataprovider to charts and the short
useless blurb in the flex 2 manual isn't helping. If I use
<mx:HTTPService to get my xml then bind that to the dataprovider to a
<mx:AreaChart it works fine:

<mx:HTTPService id="getXML"/>
...
<mx:AreaChart width="100%"
dataProvider="{getXML.lastResult.xport.data.row}">
...

Where the xml is in the form of:

<xport>
<data>
<row/>
...
</data>
</xport>

But if I try to assign the dataprovider dynamicly in actionscript
using a urlloader/urlrequest then doing a :

myXML = XML(myLoader.data);

as the docs suggest I can't just go:

myChart.dataProvider = myXML

Or any part of myXML like myXML.xport.data.row

Is there a way to stick myXML into the dataprovider or is the correct
way to go through all this MXML (I'd rather use AS)?

Thanks

__._,_.___

--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com





SPONSORED LINKS
Software development tool Software development Software development services
Home design software Software development company

Your email settings: Individual Email|Traditional
Change settings via the Web (Yahoo! ID required)
Change settings via email: Switch delivery to Daily Digest | Switch to Fully Featured
Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe

__,_._,___

Reply via email to