[thelist] Loading XML file in IE browser

Jim A zaphod_s_cousin at hotmail.com
Wed Jun 18 12:22:11 CDT 2003


Just a shot in the dark...

What version of the MSXML parser are you using on the client? Oddly, even if 
you update IE, the parser doesn't always seem to get updated to the fully 
compatible version. Below is the link to the MSXML 3.0 SP2. This cleared up 
our problems, both on our servers and clients.

http://www.microsoft.com/downloads/details.aspx?FamilyId=B1AD2C0A-8CC6-443B-AB83-F8516C72FAC1&displaylang=en


From: "Roger Ly" <evolt at matchpenalty.com>
Reply-To: "thelist at lists.evolt.org" <thelist at lists.evolt.org>
To: <thelist at lists.evolt.org>
Subject: [thelist] Loading XML file in IE browser
Date: Wed, 18 Jun 2003 09:35:33 -0700

Hey all,

I'm having a really tough time trying to debug a situation where I am
loading an external XML doc using the technique described at ppk's site
(http://www.xs4all.nl/~ppk/js/importxml.html).

In a nutshell, I have an HTML document which tries to load an external
XML doc, and use the values in that document to help populate the DOM.

I stripped down version of the page I am using is at
http://rogerly.f2o.org/blah.html (xml is at
http://rogerly.f2o.org/album.xml).

The area I am having trouble with is in this set of functions:

             function importXML(albumName)
             {
                         if (document.implementation &&
document.implementation.createDocument)
                         {
                                     xmlDoc =
document.implementation.createDocument("", "", null);
                                     xmlDoc.onload = loadAlbum;
                         }
                         else if (window.ActiveXObject)
                         {
                                     xmlDoc = new
ActiveXObject("Microsoft.XMLDOM");
                                     xmlDoc.onreadystatechange = function
() {
                                                 if (xmlDoc.readyState ==
4) loadAlbum()
                                     };
                         }
                         else
                         {
                                     alert('Your browser can\'t handle
this script');
                                     return;
                         }
                         xmlDoc.load("album.xml");
             }

             function loadAlbum()
             {
                         var album =
xmlDoc.getElementsByTagName('Album');
                         if (album.length == 0)
                         {
                                     alert('it doesnt look like the xml
was loaded properly');
                         }
                         var albumChildren = album[0].childNodes;
                         for (var i = 0; i < albumChildren.length; i++)
                         {
                                     handleAlbumChild(albumChildren[i]);
                         }
             }

In the loadAlbum() function, where I do the check to see if album.length
== 0, there are times where the Album node thinks that it doesn't have
any children.  What's weird is that usually, when I load the XML the
first time, everything works fine, but other times it doesn't work at
all.  When it fails, the top-level node read in from the Album.xml is
fine, but none of its children are loaded, which breaks everything for
me.

Does anyone have any good insight in how the Microsoft.XMLDOM ActiveX
object works?  Has anyone heard of any situations where trying to load
an XML document using that object has failed for some unknown reason?
Unfortunately, I can't think of any other ways to debug the stuff except
to throw in alerts here or there in the Javascript.

Thanks,

Roger


--
* * Please support the community that supports you.  * *
http://evolt.org/help_support_evolt/

Evolt.org conference in London, July 25-27 2003.  Register today at 
http://evolt.org.uk

For unsubscribe and other options, including the Tip Harvester
and archives of thelist go to: http://lists.evolt.org
Workers of the Web, evolt !

_________________________________________________________________
Help STOP SPAM with the new MSN 8 and get 2 months FREE*   
http://join.msn.com/?page=features/junkmail



More information about the thelist mailing list