Microsofx.XMLDOM.load() returns nothing? - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Microsofx.XMLDOM.load() returns nothing?

AdmiralNemoAdmiralNemo Posts: 2Member
Hi all,

I am doing some work in cross-browser AJAX, and I have run into a problem with Internet Explorer. No big surprise here, but this time, I can't find a solution.

Basically, I have a function that attempts to load and parse an XML document that was created dynamically in PHP on the server-side. This works great in Firefox, but in Internet Explorer, it does not.

This is the function that loads the remote document by URL. If I pass the URL to a document ending in ".xml," the alert displays the number of tags in it, as it should. However, if I pass the URL of a .php file that generates the [b]exact[/b] same content as the xml file, the element count is 0.

[code]function loadXMLDoc(url) {
if(window.ActiveXObject) {
xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async = false;
xmlDoc.load(url);
alert(url + ": " + xmlDoc.getElementsByTagName("*").length);
}
else if(document.implementation && document.implementation.createDocument) {
xmlDoc = document.implementation.createDocument("","",null);
xmlDoc.async = false;
xmlDoc.load(url);
}
return xmlDoc;
}
[/code]

Some questions you may ask:

"Does the PHP file set the HTTP Content-Type header correctly?"
Yes. Apache sends "application/xml" for xml documents, so I set PHP to do the same. Also tried "text/xml" with no love.

"Is the XML valid?"
Yes. I even tried it with a simple one-empty-element document with the same effect.

If anyone has suggestions, I would really appreciate it.

Thanks
Dustin

Comments

  • AdmiralNemoAdmiralNemo Posts: 2Member
    Well, I figured it out. Apparently, Microsoft.XMLDOM.load refuses to load SSL encrypted pages that send no-cache headers.

    This bug is documented by Microsoft: http://support.microsoft.com/kb/272359

    : Hi all,
    :
    : I am doing some work in cross-browser AJAX, and I have run into a
    : problem with Internet Explorer. No big surprise here, but this time,
    : I can't find a solution.
    :
    : Basically, I have a function that attempts to load and parse an XML
    : document that was created dynamically in PHP on the server-side.
    : This works great in Firefox, but in Internet Explorer, it does not.
    :
    : This is the function that loads the remote document by URL. If I
    : pass the URL to a document ending in ".xml," the alert displays the
    : number of tags in it, as it should. However, if I pass the URL of a
    : .php file that generates the [b]exact[/b] same content as the xml
    : file, the element count is 0.
    :
    : [code]: function loadXMLDoc(url) {
    : if(window.ActiveXObject) {
    : xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
    : xmlDoc.async = false;
    : xmlDoc.load(url);
    : alert(url + ": " + xmlDoc.getElementsByTagName("*").length);
    : }
    : else if(document.implementation && document.implementation.createDocument) {
    : xmlDoc = document.implementation.createDocument("","",null);
    : xmlDoc.async = false;
    : xmlDoc.load(url);
    : }
    : return xmlDoc;
    : }
    : [/code]:
    :
    : Some questions you may ask:
    :
    : "Does the PHP file set the HTTP Content-Type header correctly?"
    : Yes. Apache sends "application/xml" for xml documents, so I set PHP
    : to do the same. Also tried "text/xml" with no love.
    :
    : "Is the XML valid?"
    : Yes. I even tried it with a simple one-empty-element document with
    : the same effect.
    :
    : If anyone has suggestions, I would really appreciate it.
    :
    : Thanks
    : Dustin
    :

Sign In or Register to comment.