• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
Locked
0

Server Side XML Class

Participant ,
Jan 28, 2013 Jan 28, 2013

Copy link to clipboard

Copied

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....

Many thanks.

Views

531

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jan 29, 2013 Jan 29, 2013

Copy link to clipboard

Copied

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 );

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jan 30, 2013 Jan 30, 2013

Copy link to clipboard

Copied

LATEST

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines