0 Replies Latest reply on Sep 7, 2007 2:26 PM by sm689

    Linking xml dynamically with mxml

    sm689
      Hello,

      I am trying to create an application that uses an xml to source data for a chart. My mxml code is as follows :

      <!-- Simple example to demonstrate the HttpService -->
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml"
      width="100%" height="100%" creationComplete="srv.send()">
      <mx:HTTPService id="srv" url="http:/[$servername]/data.xml" />

      <mx:Panel title="Line Chart">
      <mx:LineChart id="chart"
      dataProvider="{srv.lastResult.data.result}" >
      <mx:horizontalAxis>
      <mx:CategoryAxis categoryField="slot"/>
      </mx:horizontalAxis>
      <mx:series>
      <mx:LineSeries yField="usage" name="Usage"/>
      </mx:series>
      </mx:LineChart>
      </mx:Panel>


      </mx:Application>

      In [$servername] I have the name fo my server. data.xml looks like :
      <data>
      <result slot="19:00-20:00">
      <usage>10000</usage>
      </result>
      <result slot="20:00-21:00">
      <usage>100</usage>
      </result>
      <result slot="21:00-22:00">
      <usage>500</usage>
      </result>
      <result slot="22:00-23:00">
      <usage>300</usage>
      </result>
      </data>

      This compiles but whenever I change the xml I need to recompile the mxml for it to be able to pick up the latest xml data even though I am using HTTPService. How do I link an xml dynamically with mxml so that it picks up the actual xml available instead of using the data in xml when mxml was last compiled?

      Thanks in advance