Reads a mzData v1.05 file
@param {ArrayBuffer|string} xml - ArrayBuffer or String or any Typed Array (including Node.js' Buffer from v4) with the data
@return {{times: Array<number>, series: { ms: { data:Array<Array<number>>}}}}
182824
function mzData(xml) {
  xml = ensureText(xml);

  if (typeof xml !== 'string') throw new TypeError('xml must be a string');

  let parsed = FastXmlParser.parse(xml, {
    textNodeName: '_data',
    attributeNamePrefix: '',
    parseAttributeValue: true,
    attrNodeName: '_attr',
    ignoreAttributes: false
  });

  if (!parsed.mzData) throw new Error('The parent node is not mzData');

  let result = {
    metadata: {},
    times: [],
    series: {
      ms: {
        data: []
      }
    }
  };

  processMetadata(parsed.mzData, result.metadata);

  processSpectrumList(parsed.mzData, result.times, result.series.ms.data);

  return result;
}
1182948
XMLReader getXmlReader(final String format) throws SAXException {
        if (format == null || format.equals(ATTR_FORMAT_VALUE_DITA)) {
            return reader;
        }
        for (final Map.Entry<String, String> e : parserMap.entrySet()) {
            if (format.equals(e.getKey())) {
                try {
                    // XMLReaderFactory.createXMLReader cannot be used
                    final XMLReader r = (XMLReader) Class.forName(e.getValue()).newInstance();
                    final Map<String, Boolean> features = parserFeatures.getOrDefault(e.getKey(), emptyMap());
                    for (final Map.Entry<String, Boolean> feature : features.entrySet()) {
                        try {
                            r.setFeature(feature.getKey(), feature.getValue());
                        } catch (final SAXNotRecognizedException ex) {
                            // Not Xerces, ignore exception
                        }
                    }
                    return r;
                } catch (final InstantiationException | ClassNotFoundException | IllegalAccessException ex) {
                    throw new SAXException(ex);
                }
            }
        }
        return reader;
    }
262152
private String[] readXMLDeclaration(Reader r) throws KNXMLException
	{
		final StringBuffer buf = new StringBuffer(100);
		try {
			for (int c = 0; (c = r.read()) != -1 && c != '?';)
				buf.append((char) c);
		}
		catch (final IOException e) {
			throw new KNXMLException("reading XML declaration, " + e.getMessage(), buf
				.toString(), 0);
		}
		String s = buf.toString().trim();

		String version = null;
		String encoding = null;
		String standalone = null;

		for (int state = 0; state < 3; ++state)
			if (state == 0 && s.startsWith("version")) {
				version = getAttValue(s = s.substring(7));
				s = s.substring(s.indexOf(version) + version.length() + 1).trim();
			}
			else if (state == 1 && s.startsWith("encoding")) {
				encoding = getAttValue(s = s.substring(8));
				s = s.substring(s.indexOf(encoding) + encoding.length() + 1).trim();
			}
			else if (state == 1 || state == 2) {
				if (s.startsWith("standalone")) {
					standalone = getAttValue(s);
					if (!standalone.equals("yes") && !standalone.equals("no"))
						throw new KNXMLException("invalid standalone pseudo-attribute",
							standalone, 0);
					break;
				}
			}
			else
				throw new KNXMLException("unknown XML declaration pseudo-attribute", s, 0);
		return new String[] { version, encoding, standalone };
	}
935391
function determineJSON(xml) {
	var json = null;
	parseString(xml, function(err, result) {
		if (err) {
			// TODO
			console.log(err);
		} else {
			json = result;
		}
	});
	return json;
}
1254501
function(data) {
        if(typeof data == "string") {
            data = OpenLayers.Format.XML.prototype.read.apply(this, [data]);
        }
        
        var arcNode = null;
        if (data && data.documentElement) {
            if(data.documentElement.nodeName == "ARCXML") {
                arcNode = data.documentElement;
            } else {
                arcNode = data.documentElement.getElementsByTagName("ARCXML")[0];
            }
        }
          
        // in Safari, arcNode will be there but will have a child named 
        // parsererror
        if (!arcNode || arcNode.firstChild.nodeName === 'parsererror') {
            var error, source;
            try {
                error = data.firstChild.nodeValue;
                source = data.firstChild.childNodes[1].firstChild.nodeValue;
            } catch (err) {
                // pass
            }
            throw {
                message: "Error parsing the ArcXML request", 
                error: error,
                source: source
            };
        }
        
        var response = this.parseResponse(arcNode);
        return response;
    }
1190996
def readMemory(buffer, size, URL, encoding, options):
    
    ret = libxml2mod.xmlReadMemory(buffer, size, URL, encoding, options)
    if ret is None:raise treeError('xmlReadMemory() failed')
    return xmlDoc(_obj=ret)
95326
function parsePlistXML (node) {
  var i, new_obj, key, val, new_arr, res, d;

  if (!node)
    return null;

  if (node.nodeName === 'plist') {
    new_arr = [];
    for (i=0; i < node.childNodes.length; i++) {
      // ignore comment nodes (text)
      if (!shouldIgnoreNode(node.childNodes[i])) {
        new_arr.push( parsePlistXML(node.childNodes[i]));
      }
    }
    return new_arr;

  } else if (node.nodeName === 'dict') {
    new_obj = {};
    key = null;
    for (i=0; i < node.childNodes.length; i++) {
      // ignore comment nodes (text)
      if (!shouldIgnoreNode(node.childNodes[i])) {
        if (key === null) {
          key = parsePlistXML(node.childNodes[i]);
        } else {
          new_obj[key] = parsePlistXML(node.childNodes[i]);
          key = null;
        }
      }
    }
    return new_obj;

  } else if (node.nodeName === 'array') {
    new_arr = [];
    for (i=0; i < node.childNodes.length; i++) {
      // ignore comment nodes (text)
      if (!shouldIgnoreNode(node.childNodes[i])) {
        res = parsePlistXML(node.childNodes[i]);
        if (null != res) new_arr.push(res);
      }
    }
    return new_arr;

  } else if (node.nodeName === '#text') {
    // TODO: what should we do with text types? (CDATA sections)

  } else if (node.nodeName === 'key') {
    return node.childNodes[0].nodeValue;

  } else if (node.nodeName === 'string') {
    res = '';
    for (d=0; d < node.childNodes.length; d++) {
      res += node.childNodes[d].nodeValue;
    }
    return res;

  } else if (node.nodeName === 'integer') {
    // parse as base 10 integer
    return parseInt(node.childNodes[0].nodeValue, 10);

  } else if (node.nodeName === 'real') {
    res = '';
    for (d=0; d < node.childNodes.length; d++) {
      if (node.childNodes[d].nodeType === 3) {
        res += node.childNodes[d].nodeValue;
      }
    }
    return parseFloat(res);

  } else if (node.nodeName === 'data') {
    res = '';
    for (d=0; d < node.childNodes.length; d++) {
      if (node.childNodes[d].nodeType === 3) {
        res += node.childNodes[d].nodeValue.replace(/\s+/g, '');
      }
    }

    // decode base64 data to a Buffer instance
    return new Buffer(res, 'base64');

  } else if (node.nodeName === 'date') {
    return new Date(node.childNodes[0].nodeValue);

  } else if (node.nodeName === 'true') {
    return true;

  } else if (node.nodeName === 'false') {
    return false;
  }
}
893035
public JSON read( String xml ) {
      JSON json = null;
      try{
         Document doc = new Builder().build( new StringReader( xml ) );
         Element root = doc.getRootElement();
         if( isNullObject( root ) ){
            return JSONNull.getInstance();
         }
         String defaultType = getType( root, JSONTypes.STRING );
         if( isArray( root, true ) ){
            json = processArrayElement( root, defaultType );
            if( forceTopLevelObject ){
               String key = removeNamespacePrefix( root.getQualifiedName() );
               json = new JSONObject().element( key, json );
            }
         }else{
            json = processObjectElement( root, defaultType );
            if( forceTopLevelObject ){
               String key = removeNamespacePrefix( root.getQualifiedName() );
               json = new JSONObject().element( key, json );
            }
         }
      }catch( JSONException jsone ){
         throw jsone;
      }catch( Exception e ){
         throw new JSONException( e );
      }
      return json;
   }
739506
function(element) {
      // For SVG or Symbol elements, innerHTML returns `undefined` in IE.
      // Reference: https://stackoverflow.com/q/28129956/633107
      // The XMLSerializer API is supported on IE11 and is the recommended workaround.
      var serializer = new XMLSerializer();

      return Array.prototype.map.call(element.childNodes, function (child) {
        return serializer.serializeToString(child);
      }).join('');
    }
269638
function (data) {
    if (! data.success) {
      //var timestamp = Math.round(new Date().getTime() / 1000);
      this.xml[0].children[this.testIdx].children[this.testCount].children.push({
        name: 'failure',
        attrs: {
          name: data.type,
          message:  (data.message ? data.message : 'Expected: ' + data.expected + 'Actual: ' + data.value)
        }
      });

      //if (this.variationCount > -1 && this.xml[0].children[this.testIdx].children[this.testCount].children[this.variationCount]) {
        //this.xml[0].children[this.testIdx].children[this.testCount].children[this.variationCount].attrs.end = timestamp;
      //}

      this.variationCount++;
    }

    return this;
  }
1301539
function _parseWithXml2js(xmlContent) {
  return new Promise(function(resolve, reject) {
    // parse the pom, erasing all
    xml2js.parseString(xmlContent, XML2JS_OPTS, function(err, pomObject) {
      if (err) {
        // Reject with the error
        reject(err);
      }

      // Replace the arrays with single elements with strings
      removeSingleArrays(pomObject);

      // Response to the call
      resolve({
        pomXml: xmlContent, // Only add the pomXml when loaded from the file-system.
        pomObject: pomObject // Always add the object
      });
    });
  });
}
606679
function loadXML(xml) {
            if (DOMParser) {
                try {
                    var domParser = new DOMParser();
                    var xmlDoc = domParser.parseFromString(xml, 'text/xml');
                    return xmlDoc;
                }
                catch (exp) {
                    error.raise(10103);
                }
            }
            error.raise(10004);
        }
84166
public static Map<String, String> getAttributesFromXmlFile(File xmlFile) {
        if (xmlFile == null || !xmlFile.exists())
            return Collections.emptyMap();

        try (Reader reader = createReader(xmlFile)) {
            return getAttributesFromXmlReader(reader);
        }
        catch (IOException | RuntimeException e) {
            return Collections.emptyMap();
        }
    }
767427
function (html)
    {
        var node;
        //ensure text is escaped
        if (window.DOMParser) {
            var parser = new DOMParser();
            node = parser.parseFromString(html, "text/xml");
        } else {
            node = new ActiveXObject("Microsoft.XMLDOM");
            node.async="false";
            node.loadXML(html);
        }
        return node;
    }
319967
function toJson(xml) {
    var deferred = Q.defer();
    xml2js.parseString(xml, function(err, result) {
      if (err) {
        deferred.reject(new Error(err));
      } else {
        deferred.resolve(result);
      }
    });
    return deferred.promise;
  }
57001
private XmlNode pullXmlNode() {
        // read from queue
        if(! nodeQueue.isEmpty()) {
            return nodeQueue.poll();
        }

        // read from stream
        try {
            while(reader.hasNext()) {
                int event = reader.next();
                switch(event) {
                    case XMLStreamConstants.START_ELEMENT:
                        return new XmlStartElement(reader.getLocalName(), getAttributes(reader));
                    case XMLStreamConstants.CHARACTERS:
                        // capture XML?
                        String text = filterWhitespace(reader.getText());
                        if(text.length() > 0) {
                            return new XmlContent(text);
                        }
                        break;
                    case XMLStreamConstants.END_ELEMENT:
                        return new XmlEndElement(reader.getLocalName());
                    default:
                        // do nothing
                }
            }
        } catch (XMLStreamException e) {
            throw new XmlReaderException(e);
        }
        // nothing to return
        return null;
    }
590025
def XML(uri, tc, ps, **keywords):
    '''
    '''
    source = urllib.urlopen(uri, **keywords)
    enc = source.info().getencoding()
    if enc in ['7bit', '8bit', 'binary']:
        data = source
    else:
        data = StringIO.StringIO()
        mimetools.decode(source, data, enc)
        data.seek(0)
    dom = ps.readerclass().fromStream(data)
    return _child_elements(dom)[0]