hi,
I’m trying to display my images, text using xml. but nothing is coming up, this is my xml
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<projects>
<mylist>
<images>kids.jpg</images>
<title>Kids Playing</title>
<caption>For we are young and free</caption>
</mylist>
</projects>
and this is my AS:
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("project.xml");
// count is the total number of elements in the array.
count=0;
// declare array of variable image,title and caption.
image = [];
title = [];
caption = [];
//
function loadXML(loaded) {
if (loaded) {
xmlNode = this.firstChild;
count = xmlNode.childNodes.length;
for (i=0; i<count; i++) {
image* = xmlNode.childNodes*.childNodes[0].firstChild.nodeValue;
title* = xmlNode.childNodes*.childNodes[1].firstChild.nodeValue;
caption* = xmlNode.childNodes*.childNodes[2].firstChild.nodeValue;
}
displayImages();
} else {
trace ("file not loaded!" );
}
}
// to display all elements loaded from project1.xml
function displayImages() {
for (j=0; j<count; j++) {
trace ( j+" image:"+image[j]+" title:"+title[j]+" caption:"+caption[j]);
}
}
I would appreciate your help. thank you.