[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/lib/yuilib/3.17.2/datatype-xml-parse/ -> datatype-xml-parse.js (source)

   1  /*
   2  YUI 3.17.2 (build 9c3c78e)
   3  Copyright 2014 Yahoo! Inc. All rights reserved.
   4  Licensed under the BSD License.
   5  http://yuilibrary.com/license/
   6  */
   7  
   8  YUI.add('datatype-xml-parse', function (Y, NAME) {
   9  
  10  /**
  11   * Parse XML submodule.
  12   *
  13   * @module datatype-xml
  14   * @submodule datatype-xml-parse
  15   * @for XML
  16   */
  17  
  18  Y.mix(Y.namespace("XML"), {
  19      /**
  20       * Converts data to type XMLDocument.
  21       *
  22       * @method parse
  23       * @param data {String} Data to convert.
  24       * @return {XMLDocument} XML Document.
  25       */
  26      parse: function(data) {
  27          var xmlDoc = null, win;
  28          if (typeof data === "string") {
  29              win = Y.config.win;
  30              if (win.ActiveXObject !== undefined) {
  31                  xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
  32                  xmlDoc.async = false;
  33                  xmlDoc.loadXML(data);            
  34              } else if (win.DOMParser !== undefined) {
  35                  xmlDoc = new DOMParser().parseFromString(data, "text/xml");            
  36              } else if (win.Windows !== undefined) {
  37                  xmlDoc = new Windows.Data.Xml.Dom.XmlDocument();
  38                  xmlDoc.loadXml(data);            
  39              }
  40          }
  41  
  42          if (xmlDoc === null || xmlDoc.documentElement === null || xmlDoc.documentElement.nodeName === "parsererror") {
  43          }
  44  
  45          return xmlDoc;
  46      }
  47  });
  48  
  49  // Add Parsers shortcut
  50  Y.namespace("Parsers").xml = Y.XML.parse;
  51  
  52  Y.namespace("DataType");
  53  Y.DataType.XML = Y.XML;
  54  
  55  
  56  }, '3.17.2');


Generated: Thu Aug 11 10:00:09 2016 Cross-referenced by PHPXref 0.7.1