Little back story - I created a widget to display a bunch of single text lines. I am having trouble randomizing the lines. I currently have something that will work but need to call the last tag of the xml documents that are sent to me. The only problem with this is the amount of lines are going to vary each day and the tag that i need to pull from to call the specific amount of ads is the last in the document. Just a final count of each listing. Below is the code I am using. After I get this I also need to figure out how to not have the randomly generated number overlap with the other numbers.
function loadXML(loaded) {
[COLOR=#008000]_root.adcount = this.firstChild.childNodes[0].childNodes[0].firstChild.nodeValue;[/COLOR]
[COLOR=#008000]num1.text = _root.adcount;[/COLOR]
a = Math.floor(Math.random() * 0) + 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
_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://secure.adpay.com/searchresults.aspx?p=2158®ion=2158&search="
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");
The text in Green is the line i’m trying to use to call the final tag in my xml.
XML Example:
<?xml version="1.0" encoding="ISO-8859-1"?><tcfeed>
<ad><adid>2727872</adid><copyline><![CDATA[ANTIQUE STORE LIQUIDATION AUCTIONEveryth]]></copyline></ad>
<ad><adid>2733159</adid><copyline><![CDATA[ANTIQUES - Serious Antique Dealers: Gran]]></copyline></ad>
<ad><adid>2730366</adid><copyline><![CDATA[Big & Small Hauling Service. We haul for]]></copyline></ad>
<ad><adid>2733329</adid><copyline><![CDATA[CHIHUAHUA PUPPIES. 6 weeks old. 1 male b]]></copyline></ad>
<ad><adid>2730785</adid><copyline><![CDATA[EXECUTIVE DESK & CREDENZA. Cherry finish]]></copyline></ad>
<ad><adid>2732328</adid><copyline><![CDATA[FIREARM - Antique Smith & Wesson .38 Rev]]></copyline></ad>
<ad><adid>2731403</adid><copyline><![CDATA[LABRADOR puppies. AKC, Chocolate or yell]]></copyline></ad>
<ad><adid>2732370</adid><copyline><![CDATA[LUXURY TRAVEL TRAILER 2010 36ft. Super s]]></copyline></ad>
<ad><adid>2732525</adid><copyline><![CDATA[MOTORCYCLES - Selling 3 motorcycles & tr]]></copyline></ad>
<ad><adid>2733070</adid><copyline><![CDATA[POWERCHAIR- Jet 3 Ultra. Like new. $1500]]></copyline></ad>
<ad><adid>2730233</adid><copyline><![CDATA[TRACTOR - 2 Model C Allis Chalmers- 2 ro]]></copyline></ad>
<ad><adid>2731629</adid><copyline><![CDATA[YORKIES, AKC Reg. 60 day health ins. 12w]]></copyline></ad>
[COLOR=#ff0000]<adcount>12</adcount>[/COLOR]
</tcfeed>
In red is what i’m trying to call… Any help would be greatly appreciated!