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

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

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.