5 Replies Latest reply on May 29, 2008 12:53 PM by ntsiii

    XML

    garag Level 1
      Hi,

      I have a WebService that return an XML like this:

      <PriceHistory>
      <PriceDetail>
      <Date>2004-01-02</Date>
      <Price>5.000000</Price>
      </PriceDetail>
      <PriceDetail>
      <Date>2004-01-05</Date>
      <Price>5.100000</Price>
      </PriceDetail>
      <PriceDetail>
      <Date>2004-01-06</Date>
      <Price>5.200000</Price>
      </PriceDetail>
      ...
      </PriceHistory>


      I would use the XML values to populate a LineChart, all the nodes "Date" on the x axis and all the nodes "Price" on y axis. The code that I used is the following

      var localSeries : LineSeries = new LineSeries();
      localSeries.dataProvider = XMLReturnedByWebService;
      localSeries.yField = "Price";
      localSeries.xField = "Date";

      but it doesn't work.

      My question is this: is it possible to assign to the dataProvider property of a LineSeries an XML or it is mandatory use an ArrayCollection?

      Any suggestion will be appreciate.

      Thank you very much.

      Regards.
        • 1. Re: XML
          manvitha
          Hi,

          Try with arraycollection i.e bind xml data to arraycollection and bind to the linechart
          • 2. Re: XML
            garag Level 1
            Hi manvitha,

            thank you for answer.

            If I don't format as e4x the xml webservice call results and if I cast the call result to ArrayCollection and if I return this result to my LineSeries object it, it works correctly.

            My question if is there the possibility to convert propertly and simply an XML in an ArrayCollection.

            Do you now if there is a way to do it?

            Thank you very much.

            Regards
            • 3. Re: XML
              ntsiii Level 3
              You should be able to use your e4x xml for the chart DP.

              How are you assigning a value to "XMLReturnedByWebService"?

              Is your item data in attributes or child nodes?
              Tracy
              • 4. Re: XML
                garag Level 1
                Hi Tracy,

                my web service returns me a Xml that I assign to XMLReturnedByWebService variable. The Xml returned me from WebService is this:

                <PriceHistory>
                <PriceDetail>
                <Date>2004-01-02</Date>
                <Price>5.000000</Price>
                </PriceDetail>
                <PriceDetail>
                <Date>2004-01-05</Date>
                <Price>5.100000</Price>
                </PriceDetail>
                <PriceDetail>
                <Date>2004-01-06</Date>
                <Price>5.200000</Price>
                </PriceDetail>
                ...
                </PriceHistory>

                and in order to draw the chart I use the following code:

                var localSeries : LineSeries = new LineSeries();
                localSeries.dataProvider = XMLReturnedByWebService;
                localSeries.yField = "Price";
                localSeries.xField = "Date";

                so the item data that I'm using are child nodes.

                Let me know if you need some other information.

                Thank you very much.

                garag
                • 5. Re: XML
                  ntsiii Level 3
                  If that xml is what is in the variable, then you have NOT specified the child nodes as the dataProvider, you have specified the root xml which is a single "PriceHistory" node.

                  Tracy