# Calling the last tag of an xml document... need some help

**URL:** <https://forum.kirupa.com/t/calling-the-last-tag-of-an-xml-document-need-some-help/325725>\
**Category:** Uncategorized\
**Created:** [November 1, 2011, 10:04pm UTC](https://forum.kirupa.com/t/calling-the-last-tag-of-an-xml-document-need-some-help/325725 "2011-11-01T22:04:36Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![mox911](https://avatars.discourse-cdn.com/v4/letter/m/e56c9b/32.png) [@mox911](https://forum.kirupa.com/u/mox911)\
**Post date:** [November 1, 2011, 10:04pm UTC](https://forum.kirupa.com/t/calling-the-last-tag-of-an-xml-document-need-some-help/325725/1 "2011-11-01T22:04:36Z")

</div>

Here is the current code I am using.

```auto
function loadXML(loaded) {    
[COLOR=#ff0000]_root.adcount = this.firstChild.childNodes[0].childNodes[0].firstChild.nodeValue;[/COLOR]
[COLOR=#ff0000]num1.text = _root.adcount;[/COLOR]

a = Math.floor(Math.random() * (num1.text + 1)) + 10
b = Math.floor(Math.random() * (num1.text + 1)) + 10
c = Math.floor(Math.random() * (num1.text + 1)) + 10
d = Math.floor(Math.random() * (num1.text + 1)) + 10
e = Math.floor(Math.random() * (num1.text + 1)) + 10

if (loaded) {
_root.copyline = this.firstChild.childNodes[a].childNodes[1].firstChild.nodeValue;
copyline_txt1.text = _root.copyline;
_root.adid = this.firstChild.childNodes[a].childNodes[0].firstChild.nodeValue;
ad1.text = _root.adid;

_root.copyline = this.firstChild.childNodes**.childNodes[1].firstChild.nodeValue;
copyline_txt2.text = _root.copyline;
_root.adid = this.firstChild.childNodes**.childNodes[0].firstChild.nodeValue;
ad2.text = _root.adid;

_root.copyline = this.firstChild.childNodes[c].childNodes[1].firstChild.nodeValue;
copyline_txt3.text = _root.copyline;
_root.adid = this.firstChild.childNodes[c].childNodes[0].firstChild.nodeValue;
ad3.text = _root.adid;

_root.copyline = this.firstChild.childNodes[d].childNodes[1].firstChild.nodeValue;
copyline_txt4.text = _root.copyline;
_root.adid = this.firstChild.childNodes[d].childNodes[0].firstChild.nodeValue;
ad4.text = _root.adid;

_root.copyline = this.firstChild.childNodes[e].childNodes[1].firstChild.nodeValue;
copyline_txt5.text = _root.copyline;
_root.adid = this.firstChild.childNodes[e].childNodes[0].firstChild.nodeValue;
ad5.text = _root.adid;

}
}

myPath="http://website.com..."

btn1.onRelease=function(){
if(userPath!=""){
getURL(myPath+ad1.text, "_blank");
}
}
btn2.onRelease=function(){
if(userPath!=""){
getURL(myPath+ad2.text, "_blank");
}
}
btn3.onRelease=function(){
if(userPath!=""){
getURL(myPath+ad3.text, "_blank");
}
}
btn4.onRelease=function(){
if(userPath!=""){
getURL(myPath+ad4.text, "_blank");
}
}
btn5.onRelease=function(){
if(userPath!=""){
getURL(myPath+ad5.text, "_blank");
}
}

xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("wacotcfeed.xml");

```

1. The xml comes with a random number of tags everyday. There is a tag count, but it is always the last tag on the document. I can’t figure out how to call just the last tag in the highlighted area… I need this number to display the rest of the ads without having undefined areas.

2. Once I have this complete I need the random # to not overlap and display the same ad.

I am normally an Ad designer that only needs to add occasional motion and buttons to things. This is a little beyond my knowledge base. I’m sure there is easier ways to do what I put together, but that is as far as I got. Any help would be extremely appreciated.

Thanks,  
Patrick
