Skip to main content
January 28, 2013
Question

Server Side XML Class

  • January 28, 2013
  • 1 reply
  • 591 views

Hi,

Everything I read in from my XML is of nodeType Element. I am trying to extract  the data. However because the type coming back is of type 1 (Element) I am unable to use nodeValue. What am I doing wrong? I wish to extract the directory and server information.

This is my XML

<?xml version="1.0" encoding="UTF-8"?>

<mainlist version="1" xmlns="http://xspf.org/ns/0/">

          <subList>

                    <id>

                              <title></title>

                              <creator></creator>

                              <directory>dir_data_here</directory>

                              <meta rel="server">server_info_here</meta>

                              <meta rel="version">version_here</meta>

          </id>

          </subList>

</mainlist>

This is my code:

     // Create a new XML object.

     var flooring = new XML();

     //load in the external xml data

     flooring.load("data.xml");

     // Set the ignoreWhite property to true (the default value is false).

     flooring.ignoreWhite = true;

     // After loading is complete, trace the XML object.

     flooring.onLoad = function(success) {

          //trace(flooring);

          trace( flooring.childNodes[0].childNodes[0].childNodes[0].parentNode);

          trace( flooring.childNodes[0].childNodes[0].childNodes[0].nodeValue);

          trace( flooring.childNodes[0].childNodes[0].childNodes[0].nodeType);

          trace( flooring.childNodes[0].childNodes[0].childNodes[0].nodeName);

          trace(flooring.childNodes[0].childNodes[0].childNodes[0].toString());

     }

reference:

http://help.adobe.com/en_US/flashmediaserver/ssaslr/WS5b3ccc516d4fbf351e63e3d11a11afc95e-7e2eSSASLR.html#WS5b3ccc516d4fbf351e63e3d11a11afc95e-7f20SSASLR

Many thanks.

    This topic has been closed for replies.

    1 reply

    January 30, 2013

    Hi,

    XML.load() loads an XML document from a File object or from a URL over HTTP. Since you are directly using file name as parameter in load() function, so it is treating that as a string.

    So, first create a file object and then pass it to the load() function.

    var fileObj = new File("data.xml");

    flooring.load(fileObj );

    January 30, 2013

    In fact my actual code was pulling XML from a HTTP server, like the code below.

    var flooring = new XML();

    flooring.onLoad = function(success) {

         do some stuff

         do some stuff

    };

    flooring.load(HTTP_SERVER);

    Your comment does not explain why the tags are elements and not text type. It does not matter as I have solved it another way using attributes and I decided to pull in a SMIL file rather than XML.