Edit: I didn't figure out what was wrong with my code, but I found a different script that works. Still, if anyone can tell me my error here, it would be appreciated!
AUUUUUGH! I've been working on this simple script FOREVER and I finally got it work but then something happened on my computer and I lost it and now I have to start over. And now I'm lost on the simplest part of it!
external JS:
Code:
var xmlDoc; //pass a variable to be used later
if (window.ActiveXObject) // Code for IE:
{
xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async=false;
xmlDoc.load("forum.xml"); // Path to the forum
}
else if (document.implementation && document.implementation.createDocument) // code for Mozilla, Firefox,
Opera, etc.
{
xmlDoc=document.implementation.createDocument("","",null);
xmlDoc.load("forum.xml"); // Path to the forum
}
else
{
alert('Browser error!\nYour browser is too old for this forum to parse the database.\nTo fix this
problem, upgrade to a new browser.'); //Message if browser doesnt support AJAX
}
alert(xmlDoc.getElementsByTagName("excalo")[0].getAttribute("users"));
HTML:
Code:
<html>
<head>
<script src="func.js">
</script>
</head>
<body>
<form name="register">
Username: <input type="text" value="admin" name="username"><br>
Password: <input type="password" value="admin" name="password"><br>
Password Verification: <input type="password" value="admin" name="passwordVerification"><br>
</form>
</body>
</html>
XML file forum.xml:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<excalo users="hello there">
<tester>Yo</tester>
</excalo>
I'm just trying to get an alert with the value of the users attribute. I've rewritten this code sooo much trying to get it to work, I think my mind is numb and is probably a simply solution but I just can't figure it out!
The error I'm getting in firefox is:
Quote:
|
xmlDoc.getElementsByTagName("excalo")[0] has no properties
|
The same thing happens when I try to get an alert of the "tester" element.
Edit: Except, it says
Quote:
|
xmlDoc.getElementsByTagName("tester")[0] has no properties
|
UUUGH!