Skip to Content

Gareth53.co.uk - the online home of Gareth Senior

Cross Domain XML Include

2:24p.m., Tue 1 May 2007

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

  • Muppets Birthday Card

    5:47p.m., 28 Nov

    Emma loves The Muppets. She even has her own Muppet who we call Emma Too and who was born at ...
  • Detecting Online Status In The Browser

    11:55a.m., 28 Nov

    I was just heading into a meeting when I was asked how our (mostly web-based) iOS application was going to ...
  • Dropping Support for Internet Explorer 6

    2:37p.m., 11 Oct

    Microsoft's Internet Explorer 6 has long been the bane of every front-end developer's life. It's a 10-year old browser - ...
  • Xfm Buzz - A Radio Hack

    1:15p.m., 31 May

    At Global Towers we developers have 10% time to go away and hack at something that might, ultimately, bring value ...

Blog Categories