Script: XML-text
Text from an attribute
//Loading the xml file, myText is an instance name holding the file
myText = new XML();
myText.load("xml_text1.xml");
//newText is function where we access the xml tree
myText.onLoad = newText;
//we test if loaded
if (this.loaded) {
InstanceName_0.text = "Text loaded."
}else{
InstanceName_0.text = "Text not found."
}
//accessing the tree
function newText() {
//looping through the tree
for (var count01=0; count01<=myText.childNodes.length; count01++) {
//text is the name of root node
if (this.childNodes[count01].nodeName.toLowerCase() == "text") {
//textDescryption contains all nodes
textDescryption = this.childNodes[count01];
//here we access the attribute myText containing the text file
InstanceName_0.text = textDescryption.attributes.myText;
}
}
}
|