(CS3 AS2) Ignoring or replacing empty nodes
Hi guys,
I've got an XML driven gallery with a text field for an image caption.
All is well, but, not all the images have captions and so at the moment I'm getting "undefined"
I have faced this problem before when pulling data from an rss feed and adding to a string but this time there's no string...
Below is the AS which has been adapted from a kirupa tut (i think) and I've attempted to add the solution which I used with the rss feed issue but it doesn't quite seem to work..
Any help would be great!
Cheers
Code:
//IMAGES
function loadXML(loaded) {
if (loaded) {
xmlNode = this.firstChild;
image = [];
caption = [];
total = xmlNode.childNodes.length;
for (i=0; i<total; i++) {
image[i] = xmlNode.childNodes[i].childNodes[0].firstChild.nodeValue;
caption[i] = xmlNode.childNodes[i].childNodes[1].firstChild.nodeValue;
}
caption[i] == undefined ? caption[i] = "--" : null;
}
preloadImages(0);
} else {
content = "file not loaded!";
}
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("http://www.domain.com.au/scripts/productImages.php");