Hi
Im having trouble getting Flash to return the total number <ProjectImage> nodes in the following xml.
<?xml version="1.0" ?>
<work>
<project>
<projectName>Project One</projectName>
<projectCat>Category One </projectCat>
<projectDesc>Project One Description</projectDesc>
<images>
<ProjectImage>project1-image1.jpg</ProjectImage>
<ProjectImage>project1-image2.jpg</ProjectImage>
</images>
</project>
<project>
<projectName>Project Two</projectName>
<projectCat>Category Two</projectCat>
<projectDesc>Project Two Description</projectDesc>
<images>
<ProjectImage>project2-image1.jpg</ProjectImage>
<ProjectImage>project2-image2.jpg</ProjectImage>
<ProjectImage>project2-image3.jpg</ProjectImage>
</images>
</project>
</work>
Im trying to get the Total number of images for each project. But it only returns the first image for each project…
Do I need to nest a loop within the project loop to get the images for that project?
[AS]
function loadXML(loaded) {
if (loaded) {
projectNode = this.firstChild;
projectName = [];
projectcat = [];
description = [];
image = [];
total = projectNode.childNodes.length;
for (i=0; i<total; i++) {
projectName* = projectNode.childNodes*.childNodes[0].firstChild.nodeValue;
projectcat* = projectNode.childNodes*.childNodes[1].firstChild.nodeValue;
description* = projectNode.childNodes*.childNodes[2].firstChild.nodeValue;
/// HERE IS THE PROBLEM
image* = projectNode.childNodes*.childNodes[3].childNodes[0].firstChild.nodeValue;
}
trace(total);
id = setInterval(preloadPic, 100);
} else {
content = "file not loaded!";
}
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
//xmlData.load(“assets/xml/images.xml”);
xmlData.load(“assets/xml/test.xml”);
[/AS]
Help!