XML node values into actionscript array

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • srinivasreddypn
    New Member
    • May 2007
    • 10

    XML node values into actionscript array

    Hi everybody,

    Here I am doing a project to generate flash line graphs using xml data. I prepared every thing ready for this, But only problem I am facing since so many days is from the node values in xml. My mind was blocked with this. I want to read the xml node values into the array in action script. Any help will be greatly appreciated. Here is the code:
    [code=actionscri pt]
    var fillDataArray=n ew Array();
    var productInfoArra y=new Array();
    var headingXArray=n ew Array();

    function ck() {

    /* This is the array to be read the values*/
    fillDataArray = [[], [], [], [], []];


    productInfoArra y = ['OPEN', 'HIGH', 'LOW', 'CLOSE'];
    headingXArray = ['25-06-07', '26-06-07', '27-06-07', '28-06-07', '29-06-07'];
    myGraph.init(fi llDataArray, headingXArray, productInfoArra y);
    }
    [/code]

    [code=xml]

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

    <RECORD>
    <CANVASBGCOLOR> E3ECFB</CANVASBGCOLOR>
    <SYMBOL>CONCO R</SYMBOL>
    <SERIES>EQ</SERIES>
    <OPEN>2279</OPEN>
    <HIGH>2675</HIGH>
    <LOW>2126.8</LOW>
    <CLOSE>2206.1 5</CLOSE>
    <LAST>2200</LAST>
    <PREVCLOSE>2283 .65</PREVCLOSE>
    <TOTTRDQTY>1249 8</TOTTRDQTY>
    <TOTTRDVAL>2812 4001.55</TOTTRDVAL>
    <TIMESTAMP>1-JUN-2007</TIMESTAMP>
    <DELIVERQTY>881 3</DELIVERQTY>
    </RECORD>

    <RECORD>
    <SYMBOL>CONCO R</SYMBOL>
    <SERIES>EQ</SERIES>
    <OPEN>2210</OPEN>
    <HIGH>2265</HIGH>
    <LOW>2151.55</LOW>
    <CLOSE>2172.7 5</CLOSE>
    <LAST>2170</LAST>
    <PREVCLOSE>2206 .15</PREVCLOSE>
    <TOTTRDQTY>3734 </TOTTRDQTY>
    <TOTTRDVAL>8288 918.55</TOTTRDVAL>
    <TIMESTAMP>4-JUN-2007</TIMESTAMP>
    <DELIVERQTY>214 5</DELIVERQTY>
    </RECORD>

    </CMTICKERDATA>
    [/code]
    Last edited by kestrel; Jun 26 '07, 08:19 AM. Reason: code tags, looks better
  • Motoma
    Recognized Expert Specialist
    • Jan 2007
    • 3236

    #2
    I am sorry, your question is difficult for me to understand. Could you reiterate what you are having problems with?

    Comment

    • srinivasreddypn
      New Member
      • May 2007
      • 10

      #3
      Originally posted by Motoma
      I am sorry, your question is difficult for me to understand. Could you reiterate what you are having problems with?

      Hi,

      In the AS code fillDataArray is a multidimensiona l array of four arrays. i have to call all the open values in the xml to the first array of fillDataArray. Then all the high values to the second array of fillDataArray. low values to the third array of fillDataArray. close values to the fourth array of fillDataArray.

      I have tried this in so many ways and almost i came to near that. But failed to do so, Below is the AS code that I am trying to call the node values into four individual arrays.

      function loadXMLData(loa ded) {
      if (loaded) {
      for (i=0; i<2; i++) {

      open[i] = this.firstChild .childNodes[i].childNodes[3].firstChild.nod eValue;
      high[i] = this.firstChild .childNodes[i].childNodes[4].firstChild.nod eValue;
      low[i] = this.firstChild .childNodes[i].childNodes[5].firstChild.nod eValue;
      close[i] = this.firstChild .childNodes[i].childNodes[6].firstChild.nod eValue;
      }

      But I failed to place this array values into fillDataArray. Is it the right way to solve this problem or is there any easy way, Pleae let me know.

      I hope your guidance will make me to do so, Thanks for your help.

      Sincerely,
      Srinu.

      Comment

      • Motoma
        Recognized Expert Specialist
        • Jan 2007
        • 3236

        #4
        Originally posted by srinivasreddypn
        Hi,

        In the AS code fillDataArray is a multidimensiona l array of four arrays. i have to call all the open values in the xml to the first array of fillDataArray. Then all the high values to the second array of fillDataArray. low values to the third array of fillDataArray. close values to the fourth array of fillDataArray.

        I have tried this in so many ways and almost i came to near that. But failed to do so, Below is the AS code that I am trying to call the node values into four individual arrays.

        function loadXMLData(loa ded) {
        if (loaded) {
        for (i=0; i<2; i++) {

        open[i] = this.firstChild .childNodes[i].childNodes[3].firstChild.nod eValue;
        high[i] = this.firstChild .childNodes[i].childNodes[4].firstChild.nod eValue;
        low[i] = this.firstChild .childNodes[i].childNodes[5].firstChild.nod eValue;
        close[i] = this.firstChild .childNodes[i].childNodes[6].firstChild.nod eValue;
        }

        But I failed to place this array values into fillDataArray. Is it the right way to solve this problem or is there any easy way, Pleae let me know.

        I hope your guidance will make me to do so, Thanks for your help.

        Sincerely,
        Srinu.

        I had a similar problem when I was working with Flash and XML. My problem was that the XML data was actually not loaded at the time my parse routine was being called. Try placing an else statement to notify you in the case that loaded is false. Post back your results.

        Comment

        Working...