all groups > flash actionscript > july 2005 >
You're in the

flash actionscript

group:

Getting node value by XmlConnector


Re: Getting node value by XmlConnector LuigiL
7/31/2005 12:00:00 AM
flash actionscript:
That depends on the structure of your xml-file. Here is a little code snippet
to show how you traverse a xml-document.
Open a new Flash document and put the attached AS-code on frame 1. Save the
fla. Save the attached xml-scheme as myXLM.xml in the same directory as your
fla. Test your movie.



// save as myXML.xml
<?xml version="1.0" encoding="UTF-8"?>
<data>
<picture id="0">A nice landscape</picture>
<picture id="1">A nice portrait</picture>
<picture id="2">A work of Art</picture>
</data>

// AS-code on frame 1
var myXML:XML=new XML();
myXML.ignoreWhite=true;
myXML.onLoad=function(success:Boolean){
if(success){
trace(this.childNodes.length);
trace(this.firstChild.nodeName);
trace(this.childNodes[0].nodeName);
trace(this.firstChild.childNodes.length);
trace(this.firstChild.firstChild.nodeName);
trace(this.firstChild.firstChild.attributes.id);
trace(this.firstChild.childNodes[2].attributes.id);
trace(this.firstChild.firstChild.firstChild.nodeValue);
trace(this.firstChild.childNodes[2].firstChild.nodeValue);
} else {
trace("Unable to load XML");
}
};
myXML.load("myXML.xml");
Getting node value by XmlConnector zaak79
7/31/2005 12:39:13 PM
HI all,

I am searching how to get the value of xml node to do manipulation on them. I
search many sites and still not succeeded. I tried the following:

XmlConnector.URL="data/trips.xml"

XmlConnector.trigger();

trace(XmlConnector.results.firstChild.childNodes[0].firstChild.nodeValue);

And always get:

Undefined


I appreciate your help

thanks


Re: Getting node value by XmlConnector zaak79
8/1/2005 6:55:02 AM
AddThis Social Bookmark Button