Skip to main content
calmchessplayer
Inspiring
January 25, 2010
Question

server side script help

  • January 25, 2010
  • 1 reply
  • 732 views

I'm trying to get some xml on the serverside to parse. I can load the xml just fine so there is no problem there but i can't get the streamArray to populate  nor can i get any of the if statments after loaded to execute. Here is the code feel free to use the xml document on my server.

var StreamArray = new Array();
var location_xml = new XML();


location_xml.onLoad = function( success ) {

if(location_xml.loaded == true) {
trace(location_xml);
if (location_xml.firstChild.hasChildNodes()) {

for (var aNode = location_xml.firstChild.firstChild; aNode != null; aNode=aNode.nextSibling) {

if (aNode.nodeType == 1) {

StreamArray[aNode.attributes.id] = aNode.attributes.name ;
trace(StreamArray);
}
}
}
}
}

location_xml.load("http://www.privatechatnow.com/fmsuser/playlist.xml");

    This topic has been closed for replies.

    1 reply

    January 26, 2010

    Without testing the code, I think the problem is a scope issue. When referencing an object from within a  member of the object, refer to the object as "this", rather that using the object name (as the object is not in the scope of its own members when referenced by name)

    if(this.loaded == true) {

    trace(this)

    calmchessplayer
    Inspiring
    January 26, 2010

    that worked for loaded but i still can't parse the xml data out.

    January 26, 2010

    Try tracing out the nodes as you iterate through them. I don't see an id attribute in any of the nodes in your example file... are you using the same file as your data source?

    *Edit: Strange... the XML is different than the last time I viewed it...seems to have a different structure now. When I first hit the link you posted, I got this:

    <dining-room>
          <manufacturer>The Wood Shop</manufacturer>
          <table type="round" wood="maple">
             <price>$199.99</price>
          </table>
          <chair wood="maple">
             <quantity>6</quantity>
             <price>$39.99</price>
          </chair>
       </dining-room>