Advertise here: Contact FM.


xml and safari
April 4, 2008 6:05 PM   RSS feed for this thread Subscribe

I need help accessing xml files with javascript in safari...

Ok, I've been learning javascript to make websites for my artist friends. I've got some nice code running that reads the contents of an xml file and uses that to put together a gallery of images with titles, dates, etc...
To open and access the xml file I used code I learnt here:
http://www.w3schools.com/Dom/tryit.asp?filename=try_dom_parser
All is fine until I try it out on Safari and it doesn't work at all, even that example throws an error w/ safari. Anyone have any code snipits that would work across more browsers? thanks!
posted by garethspor to computers & internet (4 comments total)
You might want to turn on the Safari debugger. Also, the error message sounds rather important for understanding the problem. Any reason why you didn't say what the error is?
posted by kamelhoecker at 7:03 PM on April 4, 2008


Safari 3 throws an error on the 'xmlDoc.load("books.xml");' line:

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

Try Googling for "document.implementation.createDocument Safari" and/or "xmlDoc.load Safari," and you'll find that others have had similar difficulties, and that the problem seems to be insoluble with this particular approach.

(My suspicion is that Safari pretends to support createDocument but that document.load doesn't really work.)

You'll probably need to find a different solution that's been more thoroughly tested for cross-browser compatibility.
posted by macrone at 7:50 PM on April 4, 2008


Does the same example work in Firefox? That may be telling.
posted by mattoxic at 3:40 AM on April 5, 2008


Hi, sorry to be so late, but I have just been having a similar issue and this thread turned up in a google search. For XML loading in Safari, check out the documentation and code example plus source [DMG] at Apple's developer site.
posted by Your Time Machine Sucks at 8:32 AM on April 28, 2008


« Older I'm going to college soon. (A...   |   My husband's dogs have done vi... Newer »
This thread is closed to new comments.