...

View Full Version : Having some Trouble...



mynameisdave145
10-17-2006, 05:49 PM
ok, so here is the code im using:


function getmessage()
{
//Get list of definition tags
var glossary = xmlDoc.getElementsByTagName('definition');
//Elements plaecholder
var elements = new Array();
//document.write(glossary.length); //Test length of glossary in words

//Using length of glossary, put information into elements placeholder
for (i=0;i<glossary.length;i++)
{
// Get words and put them into first element of array
var word_length = xmlDoc.getElementsByTagName("word");
var word = word_length[i].childNodes[0].nodeValue;
//document.write(word);
elements[i] = new Array(word);
// document.write(elements[i][0]);

//Get sections and put them into the second element of array
var section_length = xmlDoc.getElementsByTagName("section");
var section = section_length[i].childNodes[0].nodeValue;
elements[i][1] = section;

//Get definitions and put them into third element of array
var def_length = xmlDoc.getElementsByTagName("def");
var def = def_length[i].childNodes[0].nodeValue;
elements[i][2] = def;

document.write(elements[i][0]);
document.write("<br>");
document.write(elements[i][1]);
document.write("<br>");
document.write(elements[i][2]);
document.write("<br>");
}

// Rest of code is after this

The problem I run into is this: It does exactly what I want it to do, stores the data to an array and prints it exactly how I want it, however it does not seem to either exit the for loop or something weird, as the rest of the script will not run, and in firefox it prints my dad then sits there saying "Loading..." with the circle spinning.

When i comment out that entire for loop the rest of the script will run, so I have to assume it has something to do with that. Anyone have any suggestions?

_Aerospace_Eng_
10-17-2006, 06:20 PM
Where is xmlDoc defined? What is it?

mynameisdave145
10-17-2006, 06:44 PM
xmlDoc info:


<script type="text/javascript">
var xmlDoc;
function loadXML()
{
// code for IE
if (window.ActiveXObject)
{
xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async=false;
xmlDoc.load("glossary.xml");
getmessage();
}
// code for Mozilla & other browsers
else{
xmlDoc=document.implementation.createDocument("","",null);
xmlDoc.load("glossary.xml");
xmlDoc.onload=getmessage;
}
}

mynameisdave145
10-18-2006, 04:25 PM
anyone have any ideas?

mynameisdave145
10-24-2006, 05:38 PM
I am still stuck here. If anyone has any ideas or suggestions for me to try that would be very helpful. Here is my full code:


<script type="text/javascript">
var xmlDoc;
//Elements plaecholder
var elements = new Array();
function loadXML()
{
// code for IE
if (window.ActiveXObject)
{
xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async=false;
xmlDoc.load("glossary.xml");
getmessage();
}
// code for Mozilla & other browsers
else{
xmlDoc=document.implementation.createDocument("","",null);
xmlDoc.load("glossary.xml");
xmlDoc.onload=getmessage;
}
}

function getmessage()
{
//Get list of definition tags
var glossary = xmlDoc.getElementsByTagName('definition');
//document.write(glossary.length); //Test length of glossary in words

//Using length of glossary, put information into elements placeholder
for (i=0;i<glossary.length;i++)
{
// Get words and put them into first element of array
var word_length = xmlDoc.getElementsByTagName("word");
var word = word_length[i].childNodes[0].nodeValue;
//document.write(word);
elements[i] = new Array(word);
// document.write(elements[i][0]);

//Get sections and put them into the second element of array
var section_length = xmlDoc.getElementsByTagName("section");
var section = section_length[i].childNodes[0].nodeValue;
elements[i][1] = section;

//Get definitions and put them into third element of array
var def_length = xmlDoc.getElementsByTagName("def");
var def = def_length[i].childNodes[0].nodeValue;
elements[i][2] = def;

document.write(elements[i][0]);
document.write("<br>");
document.write(elements[i][1]);
document.write("<br>");
document.write(elements[i][2]);
document.write("<br>");
}

/////////////////////////////////////////////////////////////////////////

var words = new Array();
var word_count = 0;

var arrElements = document.getElementsByTagName('span');
for (i=0;i<arrElements.length;i++)
{
if(arrElements[i].className == "word")
{
words[word_count] = arrElements[i].firstChild.nodeValue;
//alert(words[word_count]);
word_count++;
}
}

}
</script>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum