SaxParser is an object that basically wraps an XMLP instance, and provides an event-based interface for parsing. This is the object users interact with when coding with XML for <SCRIPT>
553732
function(eventhandlerfactory) {

    var eventhandler = new function(){

    }

    var thehandler = function() {};
    thehandler.prototype.onStartDocument = function (funct){
      eventhandler.onStartDocument = funct;
    }
    thehandler.prototype.onEndDocument = function (funct){
      eventhandler.onEndDocument = funct;
    }
    thehandler.prototype.onStartElementNS = function (funct){
      eventhandler.onStartElementNS = funct;
    }
    thehandler.prototype.onEndElementNS = function (funct){
      eventhandler.onEndElementNS = funct;
    }
    thehandler.prototype.onCharacters = function(funct) {
      eventhandler.onCharacters = funct;
    }
    thehandler.prototype.onCdata = function(funct) {
      eventhandler.onCdata = funct;
    }
    thehandler.prototype.onComment = function(funct) {
      eventhandler.onComment = funct;
    }
    thehandler.prototype.onWarning = function(funct) {
      eventhandler.onWarning = funct;
    }

    thehandler.prototype.onError = function(funct) {
      eventhandler.onError = funct;
    }


    eventhandlerfactory(new thehandler());
    //eventhandler = eventhandler(eventhandler);
    this.m_hndDoc = eventhandler;
    this.m_hndErr = eventhandler;
    this.m_hndLex = eventhandler;
    this.m_interrupted = false;
}
386064
public void parse(InputSource inputSource) throws NodeletException {
        try {
            SAXParserFactory factory = SAXParserFactory.newInstance();
            factory.setValidating(validating);

            SAXParser parser = factory.newSAXParser();

            XMLReader reader = parser.getXMLReader();
            reader.setEntityResolver(entityResolver);
            reader.setContentHandler(new DefaultHandler() {
                private Locator locator;

                private Path path = new Path(getNodeTracker());

                private StringBuilder textBuffer = new StringBuilder();

                @Override
                public void setDocumentLocator(Locator locator) {
                    // Save the locator, so that it can be used later for line tracking when traversing nodes.
                    this.locator = locator;
                }

                @Override
                public void startDocument() throws SAXException {
                    Nodelet nodelet = nodeletMap.get("/");
                    if (nodelet != null) {
                        try {
                            nodelet.process(EMPTY_ATTRIBUTES);
                        } catch (Exception e) {
                            throw new SAXException("Error processing nodelet at the beginning of document", e);
                        }
                    }
                }

                @Override
                public void endDocument() throws SAXException {
                    NodeEndlet endlet = endletMap.get("/");
                    if (endlet != null) {
                        try {
                            endlet.process(null);
                        } catch (Exception e) {
                            throw new SAXException("Error processing nodelet at the end of document", e);
                        }
                    }
                }

                @Override
                public void startElement(String uri, String localName, String qName, Attributes attributes)
                        throws SAXException {
                    if (nodeTracker != null) {
                        nodeTracker.setName(qName);
                        nodeTracker.setLocation(locator.getLineNumber(), locator.getColumnNumber());
                    }

                    path.add(qName);
                    String pathString = path.toString();

                    Map<String, String> attrs = parseAttributes(attributes);
                    Nodelet nodelet = nodeletMap.get(pathString);
                    if (nodelet != null) {
                        try {
                            nodelet.process(attrs);
                        } catch (Exception e) {
                            if (nodeTracker != null) {
                                throw new SAXException("Error processing nodelet at start element " + nodeTracker, e);
                            } else {
                                throw new SAXException("Error processing nodelet at start element <" + qName + ">", e);
                            }
                        }
                    }

                    if (textBuffer.length() > 0) {
                        textBuffer.delete(0, textBuffer.length());
                    }
                }

                @Override
                public void endElement(String uri, String localName, String qName) throws SAXException {
                    if (nodeTracker != null) {
                        nodeTracker.setClonedNodeTracker(path.getNodeTracker());
                        nodeTracker.setLocation(locator.getLineNumber(), locator.getColumnNumber());
                    }

                    String pathString = path.toString();
                    path.remove();

                    String text = null;
                    if (textBuffer.length() > 0) {
                        text = textBuffer.toString();
                        textBuffer.delete(0, textBuffer.length());
                    }

                    NodeEndlet endlet = endletMap.get(pathString);
                    if (endlet != null) {
                        try {
                            endlet.process(text);
                        } catch (Exception e) {
                            if (nodeTracker != null) {
                                throw new SAXException("Error processing nodelet at end element " + nodeTracker, e);
                            } else {
                                throw new SAXException("Error processing nodelet at end element <" + qName + ">", e);
                            }
                        }
                    }
                }

                @Override
                public void characters(char ch[], int start, int length) throws SAXException {
                    textBuffer.append(ch, start, length);
                }

                private Map<String, String> parseAttributes(Attributes attributes) {
                    if (attributes == null) {
                        return EMPTY_ATTRIBUTES;
                    }
                    Map<String, String> attr = new HashMap<>();
                    for (int i = 0; i < attributes.getLength(); i++) {
                        attr.put(attributes.getQName(i), attributes.getValue(i));
                    }
                    return attr;
                }
            });
            reader.setErrorHandler(new ErrorHandler() {
                @Override
                public void error(SAXParseException e) throws SAXException {
                    log.error(e.toString());
                    throw e;
                }

                @Override
                public void fatalError(SAXParseException e) throws SAXException {
                    log.error(e.toString());
                    throw e;
                }

                @Override
                public void warning(SAXParseException e) throws SAXException {
                    log.warn(e.toString());
                }
            });
            reader.parse(inputSource);
        } catch (SAXParseException e) {
            throw new NodeletException("Error parsing XML; " + e);
        } catch (Exception e) {
            throw new NodeletException("Error parsing XML", e);
        }
    }
731183
def createPushParser(SAX, chunk, size, URI):
    
    ret = libxml2mod.xmlCreatePushParser(SAX, chunk, size, URI)
    if ret is None:raise parserError('xmlCreatePushParser() failed')
    return parserCtxt(_obj=ret)
26505
protected AbstractHttpOverXmpp.Data parseData(XmlPullParser parser) throws XmlPullParserException, IOException {
        NamedElement child = null;
        boolean done = false;
        AbstractHttpOverXmpp.Data data = null;
        /* We are either at start of data or end of req/res */
        if (parser.getEventType() == XmlPullParser.START_TAG) {
            while (!done) {
                int eventType = parser.next();

                if (eventType == XmlPullParser.START_TAG) {
                    switch (parser.getName()) {
                    case ELEMENT_TEXT:
                        child = parseText(parser);
                        break;
                    case ELEMENT_BASE_64:
                        child = parseBase64(parser);
                        break;
                    case ELEMENT_CHUNKED_BASE_64:
                        child = parseChunkedBase64(parser);
                        break;
                    case ELEMENT_XML:
                        child = parseXml(parser);
                        break;
                    case ELEMENT_IBB:
                        child = parseIbb(parser);
                        break;
                    case ELEMENT_SIPUB:
                        // TODO: sipub is allowed by xep-0332, but is not
                        // implemented yet
                        throw new UnsupportedOperationException("sipub is not supported yet");
                    case ELEMENT_JINGLE:
                        // TODO: jingle is allowed by xep-0332, but is not
                        // implemented yet
                        throw new UnsupportedOperationException("jingle is not supported yet");
                    default:
                        // other elements are not allowed
                        throw new IllegalArgumentException("unsupported child tag: " + parser.getName());
                    }
                } else if (eventType == XmlPullParser.END_TAG) {
                    if (parser.getName().equals(ELEMENT_DATA)) {
                        done = true;
                    }
                }
            }
            data = new AbstractHttpOverXmpp.Data(child);
        }
        return data;
    }
65871
function Parser( options ) {

  if( !(this instanceof Parser) )
    return new Parser( options )

  Stream.Transform.call( this, options )

  this._readableState.objectMode = true
  this._buffer = ''

}
699525
function plugin_parser(xmlPath) {
    this.path = xmlPath;
    this.doc = xml.parseElementtreeSync(xmlPath);
    this.platforms = this.doc.findall('platform').map(function(p) {
        return p.attrib.name;
    });
}
1251348
private Packet parseNextPacketFromPdml() {
        Packet currentPacket = null;
        int eventType;
        fieldStack.empty(); 
        try {
            eventType = parser.getEventType();
            while (eventType != XmlPullParser.END_DOCUMENT) {
                switch (eventType) {
                case XmlPullParser.START_TAG:
                    if ( parser.getRawName().contains("packet") ) { // At packet tag
                        currentPacket = setPacketProperties(xppFactory.newStartTag());
                    }
                    else if ( parser.getRawName().contains("proto") ) {
                        currentPacket = setProtoProperties(xppFactory.newStartTag(), currentPacket);
                    }
                    else if ( parser.getRawName().contains("field") ) {
                        fieldStack.push("field");
                        // Added http after all others 
                        if (protoStack.peek().equals("http") && currentPacket.isTcp()){
                            currentPacket = setHttpFieldProperties(xppFactory.newStartTag(), currentPacket);
                        }
                        else{
                        	currentPacket = setFieldProperties(xppFactory.newStartTag(), currentPacket);
                        }
                    }
                    else {
                        ;
                    }
                    break;
                case XmlPullParser.END_TAG:
                    if ( parser.getRawName().contains("packet") ) {
                        eventType = parser.next();
                        return currentPacket;
                    }
                    else if ( parser.getRawName().contains("proto") ) {
                        protoStack.pop();
                    }
                    else if ( parser.getRawName().contains("field") ) {
                        fieldStack.pop();
                    }
                default:
                }
                eventType = parser.next();
            }
            return null; // Returned if at end of pdml
        }
        catch (XmlPullParserException e) {
            e.printStackTrace();
            throw new ParserFailureException("Failed parsing pmdl " + e);
        }
        catch (IOException e) {
            e.printStackTrace();
            throw new ParserFailureException("Failed reading parser.next " + e);
        }
    }
301254
function Parser(html, opts) {
        // fake root node
        html = util.trim(html);
        this.originalHTML = html;    // only allow condition
                                     // 1. start with <!doctype
                                     // 2. start with <!html
                                     // 3. start with <!body
                                     // 4. not start with <head
                                     // 5. not start with <meta
        // only allow condition
        // 1. start with <!doctype
        // 2. start with <!html
        // 3. start with <!body
        // 4. not start with <head
        // 5. not start with <meta
        if (/^(<!doctype|<html|<body)/i.test(html)) {
            html = '<document>' + html + '</document>';
        } else {
            html = '<body>' + html + '</body>';
        }
        this.lexer = new Lexer(html);
        this.opts = opts || {};
    }
1287066
public Object parse(InputSource is) throws ParserConfigurationException, SAXException, IOException{
        SAXUtil.newSAXParser(true, false, false).parse(is, this);
        return reset();
    }
21115
final XML newXMLFromJs(Object inputObject) {
        String frag;

        if (inputObject == null || inputObject == Undefined.instance) {
            frag = "";
        } else if (inputObject instanceof XMLObjectImpl) {
            // todo: faster way for XMLObjects?
            frag = ((XMLObjectImpl) inputObject).toXMLString();
        } else {
            frag = ScriptRuntime.toString(inputObject);
        }

        if (frag.trim().startsWith("<>")) {
            throw ScriptRuntime.typeError("Invalid use of XML object anonymous tags <></>.");
        }

        if (frag.indexOf("<") == -1) {
            //    Solo text node
            return newXML(XmlNode.createText(options, frag));
        }
        return parse(frag);
    }
273295
function parse(str, options) {
  var doc = options.document || 'xml'
    , pretty = options.pretty || false
    , js = str;
  
  return ''
    + 'var ' + doc + ' = factory();\n'
    + (options.self
      ? 'var self = locals || {};\n' + js
      : 'with (locals || {}) {\n' + js + '\n}\n')
    + 'return ' + doc + '.toString({ pretty: ' + pretty + ' })';
}
502847
def parse(self, file=None, string=None):
        
        timer = metrics.Timer()
        timer.start()
        sax, handler = self.saxparser()
        if file is not None:
            sax.parse(file)
            timer.stop()
            metrics.log.debug('sax (%s) duration: %s', file, timer)
            return handler.nodes[0]
        if string is not None:
            source = InputSource(None)
            source.setByteStream(StringIO(string))
            sax.parse(source)
            timer.stop()
            metrics.log.debug('%s\nsax duration: %s', string, timer)
            return handler.nodes[0]
1201035
function HTMLReactParser(html, options) {
  if (typeof html !== 'string') {
    throw new TypeError('First argument must be a string');
  }
  return domToReact(htmlToDOM(html, domParserOptions), options);
}
438158
function parse(html, cb) {

    if (!cb) {
        throw new Error('Must pass in callback to parse() as 2nd param');
    }

    var handler = new htmlparser.DefaultHandler(function (error, dom) {
        if (error) {
            cb('Error while parsing: ' + error);
        }
        else {
            var jytObj = convertDomToJyt(dom);
            cb(null, jytObj);
        }
    }, { ignoreWhitespace: true });

    var parser = new htmlparser.Parser(handler);
    parser.parseComplete(html);
}
257178
private static SAXParser createSAXParser()
      throws ParserConfigurationException, SAXException {
    SAXParserFactory factory = SAXParserFactory.newInstance();
    factory.setValidating(false);
    factory.setXIncludeAware(false);
    factory.setFeature(
        "http://xml.org/sax/features/external-general-entities", false);
    factory.setFeature(
        "http://xml.org/sax/features/external-parameter-entities", false);
    factory.setFeature(
        "http://apache.org/xml/features/nonvalidating/load-external-dtd",
        false);
    factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);

    SAXParser parser = factory.newSAXParser();
    XMLReader xmlReader = parser.getXMLReader();
    xmlReader.setEntityResolver(NOOP_RESOLVER);
    return parser;
  }
468154
function parse() {
  var self = this;
  var xml = new expat.Parser('utf-8');
  this._parser = xml;
  this._suspended = false;
  var stack = [];
  var trace = {};
  var curr = {
    element: {},
    collect: this._collect,
    fullText: '',
    space: 0,
    path: '',
    context: {}
  };
  var fa = this._fa;
  fa.setState(this._startState);

  // A listener is assigned on opening tag encounter.
  // Here we traverse the configured finite automata use the stack
  // to form the context and trace for selector event emission.
  xml.on('startElement', function(name, attr) {
    self.emit('startElement', name, attr);
    stack.push(curr);
    trace[curr.path] = curr.element;
    var context = Object.create(curr.context);
    var element = {
      $: attr,
      $name: name,
      $text: ''
    };
    var parent = curr.element;
    curr = {
      element: element,
      collect: false,
      fullText: '',
      space: 0,
      path: curr.path + '/' + name,
      context: context
    };
    self._collect = false;
    fa.enter(name, [element, context, trace]);
    if (self._preserveLevel > 0) {
      element.$children = [];
    }
    name = element.$name;
    curr.collect = self._collect;
    if (curr.collect) {
      var container;
      if (__own.call(parent, name)) {
        container = parent[name];
        container.push(element);
      } else {
        container = [element];
        parent[name] = container;
      }
    } else {
      parent[name] = element;
      context[name] = element;
    }
    if (self._bufferLevel === 0 && self._emitData) {
      emitStart.call(self, name, element.$);
    }
  });

  // A listener is assigned on closing tag encounter.
  // Current node structure object is finalized. A selector listener is
  // invoked with current node, context, and trace; these arguments are
  // removed from the stack afterwards.
  xml.on('endElement', function(name) {
    self.emit('endElement', name);
    var prev = stack.pop();
    var element = curr.element;
    var text = curr.fullText;
    var attr = element.$;
    if (typeof attr !== 'object') {
      attr = {};
    }
    var name = element.$name;
    self._name = name;
    delete element.$;
    delete element.$text;
    delete element.$name;
    var val = element;
    if (isEmpty(element) && isEmpty(attr)) {
      val = text;
    } else if (!isEmpty(attr)) {
      element.$ = attr;
    }
    if (text !== '') {
      element.$text = text;
    }
    if (self._bufferLevel > 0 || self._preserveLevel > 0) {
      element.$name = name;
    }
    curr.context[name] = val;
    if (curr.collect) {
      var container = prev.element[name];
      container[container.length - 1] = val;
    } else {
      prev.element[name] = val;
    }
    fa.leave([element, curr.context, trace]);
    if (self._preserveLevel > 0) {
      prev.element.$children.push(val);
    }
    if (self._bufferLevel === 0 && self._emitData) {
      emitEnd.call(self, name);
    }
    curr = prev;
    this._collect = curr.collect;
  });

  // Collect node text part by part
  // (and trim leading and trailing whitespace).
  xml.on('text', function(text) {
    curr.element.$text = text;
    fa.run('state', [curr.element, curr.context, trace]);
    if (self._bufferLevel === 0 && self._emitData) {
      emitText.call(self, text);
    }
    if (!self._preserveAll) {
        var trimmed = curr.element.$text.trim();
        var spaced = curr.element.$text.substr(0, 1);
        spaced = (spaced !== '') && (spaced.trim() === '');
        var after = curr.element.$text.substr(-1, 1);
        after = (after !== '') && (after.trim() === '');
        switch (curr.space) {
          // No words yet (pass through spaces).
          case 0:
            if (trimmed !== '') {
              curr.space = after ? 2 : 1;
            }
            break;

          // Immediately after text or entity.
          case 1:
            if (trimmed === '') {
              curr.space = 2;
            } else {
              if (spaced) {
                curr.fullText += ' ';
              }
              if (after) {
                curr.space = 2;
              }
            }
            break;

          // Some words were emitted, pass through spaces again.
          // Emit spaces only when a word is encountered afterwards.
          case 2:
            if (trimmed !== '') {
              curr.fullText += ' ';
              curr.space = 1;
            }
            break;
        }
        text = self._preserveWhitespace > 0 ? text : trimmed;
        if (self._preserveLevel > 0) {
          if (text !== '') {
            curr.element.$children.push(text);
          }
        }
    }
    curr.fullText += text;
  });


  // This prelude array and string are used during encoding detection.
  // Incoming buffers are collected and parsing is postponed,
  // but only until the first tag.
  var prelude = '';
  var preludeBuffers = [];

  // Parse incoming chunk.
  // Convert to UTF-8 or emit errors when appropriate.
  var parseChunk = function(data) {
    if (self._encoder) {
      data = self._encoder.convert(data);
    }
    if (!xml.parse(data, false)) {
      self.emit('error', new Error(xml.getError()+" in line "+xml.getCurrentLineNumber()));
    }
  }

  // Pass data from stream to parser.
  this._stream.on('data', function(data) {
    if (self._encoding) {
      parseChunk(data);
    } else {
      // We can't parse when the encoding is unknown, so we'll look into
      // the XML declaration, if there is one. For this, we need to buffer
      // incoming data until a full tag is received.
      preludeBuffers.push(data);
      prelude += data.toString();
      if (/^\s*<[^>]+>/.test(prelude)) {
        var matches = prelude.match(/^\s*<\?xml[^>]+encoding="(.+?)"[^>]*\?>/);
        self._encoding = matches ? matches[1] : 'utf8';
        self._encoder = makeEncoder(self._encoding);
        for (var i = 0, n = preludeBuffers.length; i < n; i++) {
          parseChunk(preludeBuffers[i]);
        }
      }
    }
  });

  // End parsing on stream EOF and emit an *end* event ourselves.
  this._stream.on('end', function() {
    if (!xml.parse('', true)) {
      self.emit('error', new Error(xml.getError()+" in line "+xml.getCurrentLineNumber()));
    }
    self.emit('end');
  });
}
329924
function Parser(rfc822) {

    // ensure the input is a binary string
    this.rfc822 = (rfc822 || "").toString("binary");

    this._br = "";
    this._pos = 0;

    this.rawBody = "";

    this.tree = {
        childNodes: []
    };
    this._node = this.createNode(this.tree);
}