/    Sign up×
Community /Pin to ProfileBookmark

loading XML in Safari

Sorry for double-posting, but I realized this would fit better in the javascript forum.

I made a script to read a flickr photofeed. It works great, except that it doesn’t seem to load the feed with Safari. I’m not familiar with how this works. Here’s how I’m doing it now:

[CODE]function LoadRSS(rssFeed)
{
try
{
if (document.all)
{
var errorHappendHere = “Check Browser and security settings”;
xmlDoc = new ActiveXObject(“Microsoft.XMLDOM”);
}
else
{
var errorHappendHere = “Error.”;
xmlDoc = document.implementation.createDocument(“”,””,null);
}
xmlDoc.async=false;
xmlDoc.load(rssFeed);
}
catch(e)
{
alert(errorHappendHere)
}
}[/CODE]

I get the second error alert, the one that just says “Error”. Could someone point me in the right direction here?

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@UltimaterMay 07.2007 — Maybe something along these lines but it can be improved upon in several ways. Usually better to use Ajax than Sjax so JavaScript doesn't have to hold its breath 'til your function containing the XMLHttp request finishes.
<i>
</i>function LoadRSS(rssFeed)
{
try
{
if (window.ActiveXObject)
{
var errorHappendHere = "Check Browser and security settings";
xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async=false;
xmlDoc.load(rssFeed);
}
else if(window.XMLHttpRequest)
{
var errorHappendHere = "Error handling XMLHttpRequest request";
var d = new XMLHttpRequest();
d.open("GET", rssFeed, false);
d.send(null);
xmlDoc=d.responseXML;
} else {
var errorHappendHere = "Error.";
xmlDoc = document.implementation.createDocument("","",null);
xmlDoc.async=false;
xmlDoc.load(rssFeed);
}
}
catch(e)
{
alert(errorHappendHere);
}
}

Copy linkTweet thisAlerts:
@chunpanJan 29.2009 — [LIST=1]
  • [*]Include prototype.js in your page.

  • [*]Assuming you have an XML file to be parsed at this URL, "mypath/myfile.xml", it can have real contents to be parsed or an empty XML document with proper content-type header (thus you will be able to create an empty DOM object later).

  • [*]Use the following javascript:
    [CODE]
    var xmlDoc;
    var xmlURL = "mypath/myfile.xml";
    new Ajax.Request(xmlURL, {
    method: "get",
    asynchronous: false,
    onSuccess: function(resp, jsonObj) {
    xmlDoc = resp.responseXML;
    }
    });
    [/CODE]

  • [/LIST]
    ×

    Success!

    Help @consideroptions spread the word by sharing this article on Twitter...

    Tweet This
    Sign in
    Forgot password?
    Sign in with TwitchSign in with GithubCreate Account
    about: ({
    version: 0.1.9 BETA 5.20,
    whats_new: community page,
    up_next: more Davinci•003 tasks,
    coming_soon: events calendar,
    social: @webDeveloperHQ
    });

    legal: ({
    terms: of use,
    privacy: policy
    });
    changelog: (
    version: 0.1.9,
    notes: added community page

    version: 0.1.8,
    notes: added Davinci•003

    version: 0.1.7,
    notes: upvote answers to bounties

    version: 0.1.6,
    notes: article editor refresh
    )...
    recent_tips: (
    tipper: @AriseFacilitySolutions09,
    tipped: article
    amount: 1000 SATS,

    tipper: @Yussuf4331,
    tipped: article
    amount: 1000 SATS,

    tipper: @darkwebsites540,
    tipped: article
    amount: 10 SATS,
    )...