Xml| experience recently studied a bit XMLHTTP, still very interesting dongdong. I like to let it in IE6 and Firefox are running normally, the background is dom4j to parse.
1. Download Http://webfx.eae.net/dhtml/xmlextras/xmlextras.zip package, there is a xmlextras.js, take it out, I used to generate XMLHTTP objects.
2. Add the following code to the Xmlextras.js:
Check Browsers
var ua = navigator.useragent;
var opera =/opera [56789]|opera\/[56789]/i.test (UA);
var ie =!opera &&/msie [56789]/i.test (UA);
Preventing opera to be identified as IE
var Mozilla =!opera &&/mozilla\/[56789]/i.test (UA);
Preventing opera to is identified as mz/* end Browser Checks * *
if (Mozilla) {
XMLDocument.prototype.selectSingleNode = function (tagname) {
var result = This.evaluate (tagname, this, NULL, 0, NULL);
return Result.iteratenext ();
}
XMLDocument.prototype.selectNodes = function (tagname) {
var result = This.evaluate (tagname, this, NULL, 0, NULL);
var xns = new XMLNodes (result);
return XNS;
}
Defines a new class to be compatible with the return type of selectnodes () in IE.
function XMLNodes (Result) {
this.length = 0;
This.pointer = 0;
This.array = new Array ();
var i = 0;
while ((This.array[i]=result.iteratenext ())!=null)
i++;
This.length = This.array.length;
}
XMLNodes.prototype.nextNode = function () {
this.pointer++;
return this.array[pointer-1];
}
XMLNodes.prototype.reset = function () {
This.pointer = 0;
}}
Let Firefox support some of the same interfaces as IE.
3.XmlHttp return, if you need to xmlhttp.responsexml objects, in Firefox everything is normal, but in the IE6 is not often, so need to new one XmlDocument:
var doc = Xmldocument.create ();
Doc.loadxml (Xmlhttp.responsetext);
4. Use XSL to translate XML, if you want to keep spaces, you need to add
Xml:space= "preserve", for example:
<xsl:for-each select= "parameter" xml:space= "preserve" >
5. Xmlhttp.open in Firefox ("POST", url, True); The last argument cannot be false, otherwise there will be an error.