A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: XML Problem nodeValue always returns null

  1. #1
    Junior Member
    Join Date
    Dec 2006
    Posts
    6

    XML Problem nodeValue always returns null

    I am trying to import an xml file into an xml object but everytime that I access the node that I want to put into an array element using the .nodeValue the trace returns null. When I don't put the nodeValue on the end it returns the entire node xml tags and all.

    I know that I'm doing something fundamentally wrong here I just don't quite know what since xml/flash is new to me. Any help will be greatly appreciated!

    Thanks!
    schutzy

    Here's the datasource url
    http://www.hunkdish.com/upload/products.xml

    Here's the code

    products_xml = new XML();
    products_xml.onLoad = initializeXML;
    products_xml.load("http://www.hunkdish.com/upload/products.xml");
    products_xml.ignoreWhite = true;
    var productnames = new Array();
    var prices = new Array();

    function initializeXML(success) {
    if (success)
    {
    rootNode = products_xml.firstChild;
    mediatype = rootNode.firstChild.firstChild[1];
    numElements = rootNode.childNodes.length;
    for(i = 0 ; i < numElements ; i++){
    productnames[i] = rootNode.childNodes[i].attributes.name;
    trace(productnames[i]);// outputs the product's name
    /*
    prices[i] = rootNode.childNodes[i].childNodes[2].nodeValue; // returns the node but with the xml tags
    trace prices[i]);
    */
    prices[i] = rootNode.childNodes[i].childNodes[2].nodeValue; // this always returns null
    trace(prices[i]);
    }// end for
    }// end if
    }// end function

  2. #2
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    Code:
    trace(productnames[i]);
    prices[i] = rootNode.childNodes[i].childNodes[2].childNodes; 
    trace (prices[i]);
    output -
    PHP Code:
    18x24 Gloss Paper
    19.50
    22x29 Gloss Paper
    28.80
    24x32 Gloss Paper
    34.67
    27x36 Gloss Paper
    37.13 

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