# Simple xml question

**URL:** <https://forum.kirupa.com/t/simple-xml-question/170847>\
**Category:** Uncategorized\
**Created:** [November 29, 2005, 10:30pm UTC](https://forum.kirupa.com/t/simple-xml-question/170847 "2005-11-29T22:30:06Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![tomms](https://avatars.discourse-cdn.com/v4/letter/t/258eb7/32.png) [@tomms](https://forum.kirupa.com/u/tomms)\
**Post date:** [November 29, 2005, 10:30pm UTC](https://forum.kirupa.com/t/simple-xml-question/170847/1 "2005-11-29T22:30:06Z")

</div>

how would i change this code to load a random image?

function loadXML(loaded) {  
if (loaded) {  
xmlNode = this.firstChild;  
image = [];  
description = [];  
total = xmlNode.childNodes.length;  
for (i=0; i\<total; i++) {  
image\* = xmlNode.childNodes\*.childNodes[0].firstChild.nodeValue;  
description\* = xmlNode.childNodes\*.childNodes[1].firstChild.nodeValue;  
}  
firstImage();  
} else {  
content = “file not loaded!”;  
}  
}  
xmlData = new XML();  
xmlData.ignoreWhite = true;  
xmlData.onLoad = loadXML;  
xmlData.load(“images.xml”);
