Guest Shannon Posted November 8, 2006 Share Posted November 8, 2006 Hi, I'm new to this forum so I don't know if I'm going against any rules, but I need help. I'm working on a school webpage that will be desplaying information about our professors. I have an XML document type up with doesn't have a DTD or a shema but that hasn't been a problem so far. I put together the following code, that works fine in IE, but not Firefox.This is where I'm parsing the data for different browsers. <head> <script type = "text/javascript" language = "javascript"> <!-- var xmlDocument if (window.ActiveXObject) { xmlDocument=new ActiveXObject("Microsoft.XMLDOM"); xmlDocument.async=false; xmlDocument.load("staff.xml"); } // code for Mozilla, Firefox, Opera, etc. else if (document.implementation && document.implementation.createDocument) { xmlDoc=document.implementation.createDocument("","",null); xmlDoc.load("note.xml"); } else { alert('Your browser cannot handle this script'); } --> </script></head> And this is what I'm trying to display with the DOM <body> <script type = "text/javascript" language = "javascript"> <!-- //get root element var professors = xmlDocument.documentElement; var professor = professors.childNodes.item(1); var name = professor.childNodes.item(0); var rank = professor.childNodes.item(5); var location = professor.childNodes.item(1); var phone = professor.childNodes.item(2); var email = professor.childNodes.item(3); document.write(name.firstChild.nodeValue + "<br>" + rank.firstChild.nodeValue + "<br>"); document.write("<br><img src=\"" + professor.getElementsByTagName("Image")[0].firstChild.nodeValue + "\"><br>"); document.write("<b>Office:</b>"); document.write("<br/>"); document.write("<ul>"); document.write("<li><i>Location</i> - " + location.firstChild.nodeValue + "</li>"); document.write("<li><i>Phone</i> - " + phone.firstChild.nodeValue + "</li>"); document.write("<li><i>E-mail</i> - <a href=\"mailto:" + email.firstChild.nodeValue + "\">"+ email.firstChild.nodeValue + "</a></li>"); document.write("<li><i>Postal Address</i> - </li>"); document.write("</ul>"); document.write("<blockquote>"); document.write("<blockquote>" + name.firstChild.nodeValue); document.write("<br>C/O Computer Science Department<br>East Stroudsburg University<br>East Stroudsburg, Pa 18301"); document.write("</blockquote>"); document.write("</blockquote>"); document.write("<b>Degrees:</b>"); document.write("<br>"); document.write("<ul>"); for( var i = 0; i < professor.getElementsByTagName("Degree").length; i++){ document.write("<li>" + professor.getElementsByTagName("Degree")[i].firstChild.nodeValue + "</li>"); } document.write("</ul>"); --> </script></body> As I said the code works fine in IE but all I get is a blank page when it is opened in Firefox. I'm hoping there is a simple way to fix this problem. Otherwise I think I might have to redo the whole page. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now