Skip to content
Permalink
Browse files
XML: Refactor of feature detecting logic.
  • Loading branch information
Ezequiel Rodriguez committed Nov 25, 2013
1 parent cc4eed2 commit 680a9e80751528748eb64857eb80745eb66d0dd3
Showing with 13 additions and 25 deletions.
  1. +13 −25 src/xml/js/xml-parse.js
@@ -6,8 +6,6 @@
* @for XML
*/

var LANG = Y.Lang;

Y.mix(Y.namespace("XML"), {
/**
* Converts data to type XMLDocument.
@@ -17,32 +15,22 @@ Y.mix(Y.namespace("XML"), {
* @return {XMLDoc} XML Document.
*/
parse: function(data) {
var xmlDoc = null;
if(LANG.isString(data)) {
try {
if(!LANG.isUndefined(ActiveXObject)) {
xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async = false;
xmlDoc.loadXML(data);
}
}
catch(ee) {
try {
if (!LANG.isUndefined(DOMParser)) {
xmlDoc = new DOMParser().parseFromString(data, "text/xml");
}
if (!LANG.isUndefined(Windows.Data.Xml.Dom)) {
xmlDoc = new Windows.Data.Xml.Dom.XmlDocument();
xmlDoc.loadXml(data);
}
}
catch(e) {
}
Y.log(ee.message + " (Could not initialize the ActiveX control for XML parsing)", "warn", "xml");
var xmlDoc = null, win;
if (typeof data === "string") {
win = Y.config.win;
if (win.DOMParser !== undefined) {
xmlDoc = new DOMParser().parseFromString(data, "text/xml");
} else if (win.ActiveXObject !== undefined) {
xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async = false;
xmlDoc.loadXML(data);
} else if (win.Windows !== undefined) {
xmlDoc = new Windows.Data.Xml.Dom.XmlDocument();
xmlDoc.loadXml(data);
}
}

if( (LANG.isNull(xmlDoc)) || (LANG.isNull(xmlDoc.documentElement)) || (xmlDoc.documentElement.nodeName === "parsererror") ) {
if (xmlDoc === null || xmlDoc.documentElement === null || xmlDoc.documentElement.nodeName === "parsererror") {
Y.log("Could not parse data to type XML Document", "warn", "xml");
}

0 comments on commit 680a9e8

Please sign in to comment.