1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
|
/**
* APIMethod: read
* Deserialize a XML string and return a DOM node.
*
* Parameters:
* text - {String} A XML string
*
* Returns:
* {DOMElement} A DOM node
*/
OpenLayers.Format.XML.prototype.read= function(text) {
var index = text.indexOf('<');
if(index > 0) {
text = text.substring(index);
}
var node = OpenLayers.Util.Try(
OpenLayers.Function.bind((
function() {
var xmldom;
/**
* Since we want to be able to call this method on the prototype
* itself, this.xmldom may not exist even if in IE.
*/
if(window.ActiveXObject && !this.xmldom) {
xmldom = new ActiveXObject("Microsoft.XMLDOM");
} else {
xmldom = this.xmldom;
}
xmldom.loadXML(text);
return xmldom;
}
), this),
function() {
return new DOMParser().parseFromString(text, 'text/xml');
},
function() {
var req = new XMLHttpRequest();
req.open("GET", "data:" + "text/xml" +
";charset=utf-8," + encodeURIComponent(text), false);
if(req.overrideMimeType) {
req.overrideMimeType("text/xml");
}
req.send(null);
return req.responseXML;
}
);
/* IGNF
var pet= OpenLayers.Request.XMLHttpRequest.getParseErrorText(node);
if (pet != OpenLayers.Request.XMLHttpRequest.PARSED_OK &&
pet != OpenLayers.Request.XMLHttpRequest.PARSED_EMPTY) {
alert(OpenLayers.i18n(pet));
}
*/
if(this.keepData) {
this.data = node;
}
return node;
}; |
Partager