A Flash Developer Resource Site

Results 1 to 7 of 7

Thread: sort of Parsing/split text problems

  1. #1
    Member
    Join Date
    Mar 2007
    Posts
    31

    sort of Parsing/split text problems

    This is the code to bring the XML into flash,

    importXMLGOLD = new XML();
    importXMLGOLD.ignoreWhite = true;
    importXMLGOLD.onLoad = function(successGOLD)
    {
    if (successGOLD)
    {

    var rootGOLD = this.firstChild.childNodes; // The root node

    var curcodeGOLD = [];


    trace(rootGOLD.length);
    for (var rGOLD = 0; rGOLD < rootGOLD.length; rGOLD++)
    {
    //push each to an array value

    curcodeGOLD[rGOLD] = rootGOLD[rGOLD].childNodes[10].childNodes[0].firstChild.nodeValue;


    }
    }
    //check the arrays
    for (var nGOLD = 0; nGOLD < curcodeGOLD.length; nGOLD++) {

    trace (curcodeGOLD[nGOLD]);
    realGoldM.realGold.text = curcodeGOLD[0];
    }
    //end check


    }
    importXMLGOLD.load("realgold.php");
    http://ansuz.sooke.bc.ca/rippy/comm-...=AuAM&mode=rss

    that is the XML feed

    and i get the data out of <item> <title>..

    i need to get the data out of this,
    04-May-07 London gold, AM fix: 680.80 (+4.90)
    i just want the last numbers, 680 onwards..

    i can get all of it in but i dont want it all! just the numbers

    cheers if you can pish me in the right direction!


  2. #2
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    Code:
    //check the arrays
    for (var nGOLD = 0; nGOLD < curcodeGOLD.length; nGOLD++) {
    
    trace (curcodeGOLD[nGOLD]);
    str = curcodeGOLD[0];
    len = str.length;
    id = str.lastIndexOf(":");
    str = str.substr(id+2,len)
    trace(str);
    realGoldM.realGold.text = str;
    }
    //end check
    hth

  3. #3
    Member
    Join Date
    Mar 2007
    Posts
    31

    thats a bit different from the one i got given elsewhere

    importXMLother = new XML();
    importXMLother.ignoreWhite = true;
    importXMLother.onLoad = function(successother)
    {
    if (successother)
    {

    var rootother = this.firstChild.childNodes; // The root node

    var curcodeother = [];


    trace(rootother.length);
    for (var rother = 0; rother < rootother.length; rother++)
    {
    //push each to an array value

    curcodeother[rother] = rootother[rother].childNodes[10].childNodes[0].firstChild.nodeValue;


    }
    }
    //check the arrays
    for (var nother = 0; nother < curcodeother.length; nother++) {

    trace (curcodeother[nother]);
    //
    var palStr:String = curcodeother[nother];
    var palSplit:Array = palStr.split(" ");
    var palLast:String = palSplit[palSplit.length-2];
    realCopperM.realCopper.text = palLast;
    }
    //end check


    }
    importXMLother.load("realpalladium.php");
    Exceeeeeeeellent

    now im having problems with the next one!

  4. #4
    Member
    Join Date
    Mar 2007
    Posts
    31
    for (var nbase = 0; nbase < curcodebase.length; nbase++) {

    //trace (curcodebase[nbase]);
    //
    var baseStr:String = curcodebase[nbase];
    var baseSplit:Array = baseStr.split("<TABLE><TR><TH>Base</TH><TH>USD bid</TH><TH>USD ask</TH></TR><TR><TD>Copper</TD><TD>");
    var baseLast:String = baseSplit[baseSplit.length-1];

    var baseBall:String = baseLast;
    var baseSplitter:Array = baseBall.split(" ");
    var baseLONG:String = baseSplitter[baseSplitter.length-1];


    //realIronM.realIron.text = baseLast;
    trace (baseLast);
    }
    im using that to try and split this xml file in description

    http://ansuz.sooke.bc.ca/rippy/comm-...=Base&mode=rss

    at current it is leaving me at 3.7943</TD><TD>3.8034</TD></TR><TR><TD>Nickel</TD><TD>23.8393</TD><TD>23.8506</TD></TR><TR><TD>Aluminum</TD><TD>1.2843</TD><TD>1.2847</TD></TR><TR><TD>Zinc</TD><TD>1.7580</TD><TD>1.7625</TD></TR><TR><TD>Lead</TD><TD>0.9525</TD><TD>0.9547</TD></TR></TABLE><P>RSS feed sponsored by <A HREF="http://ansuz.sooke.bc.ca/bonobo-conspiracy/?r=cpfs">Bonobo Conspiracy</A>; data from <A HREF="http://www.kitcometals.com/">Kitco</A>; more <A HREF="http://ansuz.sooke.bc.ca/rippy/comm-prices/">info</A></P>
    </description>

  5. #5
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    you've lost me there mate

    1st post you use - for (var rGOLD = 0; rGOLD < rootGOLD.length; rGOLD++)
    2nd post you use - for (var nother = 0; nother < curcodeother.length; nother++)
    3rd post you use - for (var nbase = 0; nbase < curcodebase.length; nbase++)

    not one thing in 3 posts are in common,......totally lost

  6. #6
    Ryan Thomson EvolveDesigns's Avatar
    Join Date
    Oct 2001
    Location
    British Columbia
    Posts
    3,338
    Well that's the first reference to Sooke BC I've seen online sorry don't mind me
    Evolve Designs Interactive Media
    the natural selection

  7. #7
    Member
    Join Date
    Mar 2007
    Posts
    31
    hahaha

    ive been at this for 14 hours now in one day alone

    in the end i just shortened the dynamic textbox so it just reached the digits i wanted.

    it wont help me later but im too tired to care

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center