PDA

View Full Version : how to read xml file from safari?



onoprise
12-06-2008, 10:41 PM
i am currently using the code below from w3schools to parse a xml file and it works fine in firefox and ie, but when i try to view the site from safari, i get an error

here is the error from safari:

Value undefined (result of expression xmlDoc.load) is not object.

i am using the following code (originally from w3schools (http://www.w3schools.com/Dom/tryit.asp?filename=try_dom_parser)):

function loadXMLDoc(dname)
{
try //Internet Explorer
{
xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
}
catch(e)
{
try //Firefox, Mozilla, Opera, etc.
{
xmlDoc=document.implementation.createDocument("","",null);
}
catch(e) {alert(e.message)}
}
try
{
xmlDoc.async=false;
xmlDoc.load(dname);
return(xmlDoc);
}
catch(e) {alert(e.message)}
return(null);
}

i tried following the xmlhttpreq example from apple (http://developer.apple.com/internet/webcontent/xmlhttpreq.html), but i couldnt get to work.

if anyone has any advise, i'm all ears. thanks in advance.

diltony
12-16-2008, 10:55 PM
Why not use some server scripts to do the parsing? that way u can avoid browser dependency errors, i am not sure of ur favorite server language, i usually work with jscript/php/mysql/ajax, but i know that all server languages like asp, asp.net...can parse xml properly