Cross Domain XML Include
I've just built an online radio player - a web page with an embedded windows media player object. The client also wanted the player to show the current DJ and the current track with both chunks of information available in XML format.
Simple enough I thought - load the XML using the ActiveX plug-in (or using document.implementation.createDocument) a bit of DOM script to parse the XML object I create and there you go - your standard AJAX stuff. Except.... the 2 XML files are on different domains.
The default security settings allow sloppy old IE mean to load a file from a different domain via a XMLhttpRequest object but other browsers (most notably Firefox) won't by default, not without the user adding the domain to their "trusted domains" list or manually changing the relevant security setting.
I figured I could load the remote file using an ASP script and re-write the XML to present to the browser. I read hundreds of articles and forum threads on line that told me it couldn't be done. But I managed to get it working. Here's the vbscript:
Response.ContentType = "text/xml" set xmldoc = Server.CreateObject("Microsoft.XMLDOM") xmldoc.async=false xmldoc.setProperty "ServerHTTPRequest", true xmldoc.Load("http://www.xxxxxx.xxx/feed.xml")
(IE was happy with loading XML from a file with the .asp file extension, but Firefox needed the mimetype explicitly declared.)
I then looped through the XML file and pretty much re-wrote the attributes and node.values that were found. It felt wrong, like an unnecessary step, it's definitely not a technique I would plan to use, but sometimes needs must.
Latest Posts
iPhone App: Flick Cricket
10:15a.m., 4 Sep
Cricket seems like a ridiculous sport to me. I like hitting the ball - hitting a ball as hard as ...Javascript from the wonderful world of online advertising
8:23p.m., 1 Sep
I had a right old rant about the quality of javascript that you find being served by major providers of ...Web performance - Analysing Heart.co.uk
5:17p.m., 26 Aug
A few weeks back I, together with m'colleague Jon Topper, delivered a presentation about the performance of heart.co.uk to the ...Installing MySQL and MySQLdb on OSX
10:19a.m., 19 Aug
I've just set up my dev environment for Django. Again. This is the fourth time I've had to do it. ...