I can not display the data from an XML file. My code is like this:
function getdata() {
myXML=new XML();
myXML.onLoad=disp;
myXML.load(“xmldata.xml”);
}
function disp() {
trace(“disp”);
trace(myXML.firstChild.firstChild.nodeValue);
}
the content of “xmldata.xml” is :
<ABC>
<TRYING>sample data</TRYING>
</ABC>
getdata fn is called on click of a button. when i run the application it goes to the disp function but doesnot display the the data from XML file.
can anybody help me…
thanks in advance
The key to your code working should be adding an "ignorewhite" value to your XML object. That's if your using Flash MX or Flash 5 with player version 5.0.41 or later. The new code should look like this:
myXML=new XML();
myXML.ignoreWhite = true; // !!! new line !!!
myXML.onLoad=disp () ;
myXML.load(“xmldata.xml”);
If this doesn't work you might also want to check the status of your XML object. Doing so allows you see if your XML document was parsed correctly. Just add : trace (myXML.status); . You want to get back a zero . If you get another number here is the list of all of the return values for status and what they mean:
0 No error; parse was completed successfully.
-2 A CDATA section was not properly terminated.
-3 The XML declaration was not properly terminated.
-4 The DOCTYPE declaration was not properly terminated.
-5 A comment was not properly terminated.
-6 An XML element was malformed.
-7 Out of memory.
-8 An attribute value was not properly terminated.
-9 A start-tag was not matched with an end-tag.
-10 An end-tag was encountered without a matching start-tag.
// List of values provided by Macromedia’s ActionScript Dictionary.
I m using FLASH MX. I tried myXML.ignoreWhite = true; also.
& checked the status: trace(myXML.status); it returns zero means there is no error in parsing but still i m unable to dispaly the value…
pls help
That would probably help a lot. I have also found that using attributes such as “id” for the information is idea for Flash’s ActionScript. At least this is what I have found.