2 YUI 3.13.0 (build 508226d)
3 Copyright 2013 Yahoo! Inc. All rights reserved.
4 Licensed under the BSD License.
5 http://yuilibrary.com/license/
8 YUI.add('datatype-xml-parse', function (Y, NAME) {
11 * Parse XML submodule.
13 * @module datatype-xml
14 * @submodule datatype-xml-parse
20 Y.mix(Y.namespace("XML"), {
22 * Converts data to type XMLDocument.
25 * @param data {String} Data to convert.
26 * @return {XMLDoc} XML Document.
28 parse: function(data) {
30 if(LANG.isString(data)) {
32 if(!LANG.isUndefined(ActiveXObject)) {
33 xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
40 if (!LANG.isUndefined(DOMParser)) {
41 xmlDoc = new DOMParser().parseFromString(data, "text/xml");
43 if (!LANG.isUndefined(Windows.Data.Xml.Dom)) {
44 xmlDoc = new Windows.Data.Xml.Dom.XmlDocument();
50 Y.log(ee.message + " (Could not initialize the ActiveX control for XML parsing)", "warn", "xml");
54 if( (LANG.isNull(xmlDoc)) || (LANG.isNull(xmlDoc.documentElement)) || (xmlDoc.documentElement.nodeName === "parsererror") ) {
55 Y.log("Could not parse data to type XML Document", "warn", "xml");
62 // Add Parsers shortcut
63 Y.namespace("Parsers").xml = Y.XML.parse;
65 Y.namespace("DataType");
66 Y.DataType.XML = Y.XML;