Parses a single xml file.  If {@code utterancePerDoc} is true, each
utterance will be on a separate line, otherwise they will all be
concantanated, and separated by periods, and stored on a single line.
779327
public void parseFile(File file, boolean utterancePerDoc) {
        try {
            // Build an xml document.
            DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
            DocumentBuilder db = dbf.newDocumentBuilder();
            Document doc = db.parse(file);

            // Extract all utterances.
            NodeList utterances = doc.getElementsByTagName("u");
            StringBuilder fileBuilder = new StringBuilder();
            for (int i = 0; i < utterances.getLength(); ++i) {
                // Extract all words from the utterance
                Element item = (Element) utterances.item(i);
                NodeList words = item.getElementsByTagName("w");
                StringBuilder utteranceBuilder = new StringBuilder();

                // Iterate over the words and get just the word text.
                List<String> wordsInUtterance =
                    new ArrayList<String>(words.getLength());
                for (int j = 0; j < words.getLength(); ++j) {
                    // Get the part of speech tag.
                    Element wordNode = (Element) words.item(j);
                    NodeList posNodeList = wordNode.getElementsByTagName("pos");
                    String word = wordNode.getFirstChild().getNodeValue();
                    if (posNodeList.getLength() > 0) {
                        Node posNode = 
                            posNodeList.item(0).getFirstChild().getFirstChild();
                        String pos = posNode.getNodeValue();
                        posTags.put(word, pos);
                        if (appendPosTags)
                            word += "-" + pos;
                    }
                    wordsInUtterance.add(word);
                }

                // Each of the <a> nodes contains additional information about
                // the currnet utterances.  This may be syntactic information,
                // comments on the scene, descriptions of the action, or
                // clarification by the observer.  For all comments but the
                // syntactic, use the comment text to create new pseudo
                // utterances by combining tokens from the utterance with
                // pseudo-tokens in the comment.  The pseudo-tokens have a
                // "-GROUNDING" suffix which distiguishes them from tokens
                // actually present in the uttered speech.
                NodeList auxNodes = item.getElementsByTagName("a");
                List<String> augmentedUtterances = new LinkedList<String>();
                if (generateAugmented) {
                    for (int j = 0; j < auxNodes.getLength(); ++j) {
                        // Get any comment for the utterance
                        Node n = auxNodes.item(j);
                        String auxNodeType = n.getAttributes().
                            getNamedItem("type").getNodeValue();

                        // Get only those nodes that contain comments or
                        // descriptions on the utterance that may be used to
                        // ground the words being referred to.
                        if (auxNodeType.equals("action")
                            || auxNodeType.equals("actions")
                            || auxNodeType.equals("addressee")
                            || auxNodeType.equals("comments")
                            || auxNodeType.equals("explanation")
                            || auxNodeType.equals("gesture")
                            || auxNodeType.equals("happening")
                            || auxNodeType.equals("situation")) {
                            
                            String commentOnUtterance = 
                                n.getFirstChild().getNodeValue();
                            // Use the iterator factory to tokenize in the event
                            // that the user has specified some form of token
                            // filtering
                            Iterator<String> tokenIter = 
                                IteratorFactory.tokenize(
                                        new BufferedReader(
                                            new StringReader(
                                                commentOnUtterance)));
                            // For each of the tokens in the additional
                            // information, create a pseudo-utterance using a
                            // word from the actual utterance and an
                            // grounding-token
                            while (tokenIter.hasNext()) {
                                String token = tokenIter.next();
                                for (String word : wordsInUtterance) {
                                    augmentedUtterances.add(word + " "
                                        + token + "-GROUNDING");
                                }
                            }
                        }
                    }
                }
                    
                // Write the utterance if an utterance is a document.
                for (Iterator<String> it = wordsInUtterance.iterator(); 
                         it.hasNext(); ) {
                    utteranceBuilder.append(it.next());
                    if (it.hasNext())
                        utteranceBuilder.append(" ");
                }
                String utterance = utteranceBuilder.toString();
                if (utterancePerDoc) {
                    print(utterance);
                    // Print all the psuedo utterances constructed from the
                    // comments
                    for (String aug : augmentedUtterances)
                        print(aug);
                }
                else {  // otherwise save the utterance.
                    fileBuilder.append(utterance);
                    if (separateByPeriod)
                        fileBuilder.append(".");
                    fileBuilder.append(" ");

                    // Print all the psuedo utterances constructed from the
                    // comments.  Unlike the utterances, print these as separate
                    // documents to avoid having them register as co-occurrences
                    // with other utterances.
                    for (String aug : augmentedUtterances)
                        print(aug);
                }
            }

            // Write all the utterances if the whole xml file is a document.
            if (!utterancePerDoc)
                print(fileBuilder.toString());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
1205031
public static <T> List<T> parseListFrom(XMLStreamReader parser, Schema<T> schema)
            throws IOException, XMLStreamException
    {
        if (parser.nextTag() != START_ELEMENT || !"list".equals(parser.getLocalName()))
            throw new XmlInputException("Expected token START_ELEMENT: list");

        // final String simpleName = schema.messageName();
        final ArrayList<T> list = new ArrayList<T>();
        final XmlInput input = new XmlInput(parser);

        for (int tag = parser.nextTag(); tag != END_ELEMENT; tag = parser.nextTag())
        {
            if (tag != START_ELEMENT || !schema.messageName().equals(parser.getLocalName()))
                throw new XmlInputException("Expected token START_ELEMENT: " + schema.messageName());

            final T message = schema.newMessage();

            if (parser.nextTag() == END_ELEMENT)
            {
                // if(!simpleName.equals(parser.getLocalName()))
                // throw new XmlInputException("Expecting token END_ELEMENT: " + simpleName);

                // empty message
                list.add(message);
                continue;
            }

            schema.mergeFrom(input, message);

            // if(!simpleName.equals(parser.getLocalName()))
            // throw new XmlInputException("Expecting token END_ELEMENT: " + simpleName);

            list.add(message);
        }

        return list;
    }
1281352
@Override
    public JingleContentDescription parse(XmlPullParser parser,
                    int initialDepth, XmlEnvironment xmlEnvironment) throws XmlPullParserException,
                    IOException {
        boolean done = false;
        JingleContentDescription desc = getInstance();

        while (!done) {
            int eventType = parser.next();
            String name = parser.getName();

            if (eventType == XmlPullParser.START_TAG) {
                if (name.equals(JingleContentDescription.JinglePayloadType.NODENAME)) {
                    desc.addJinglePayloadType(parsePayload(parser));
                } else {
                    // TODO: Should be SmackParseException.
                    throw new IOException("Unknow element \"" + name + "\" in content.");
                }
            } else if (eventType == XmlPullParser.END_TAG) {
                if (name.equals(JingleContentDescription.NODENAME)) {
                    done = true;
                }
            }
        }
        return desc;
    }
344718
public void parse(File f, DefaultHandler dh) throws SAXException, IOException
    {
        XMLReader reader = getXMLReader();
        InputSource source = new InputSource(new FileInputStream(f));
        reader.setContentHandler(dh);
        reader.parse(source);
    }
936710
public synchronized void parseLine(String line) throws SyntaxErrorException
	{
		if (null != getParserOutcome() && isParserOutcomeMultipleLine())
		{
			parseLine__multipleLineMode(line);
		}
		else
		{
			parseLine__singleLineMode(line);
		}
	}
710757
public XmlPullParser newPullParser() throws XmlPullParserException {
        final XmlPullParser pp = getParserInstance();
        for (Map.Entry<String, Boolean> entry : features.entrySet()) {
            // NOTE: This test is needed for compatibility reasons. We guarantee
            // that we only set a feature on a parser if its value is true.
            if (entry.getValue()) {
                pp.setFeature(entry.getKey(), entry.getValue());
            }
        }

        return pp;
    }
335631
public void parse(InputStream xmlInput) throws XMLStreamException {
    InputStream input = isoControlCharsAwareParser ? new ISOControlCharAwareInputStream(xmlInput) : xmlInput;
    parse(inf.rootElementCursor(input));
  }
622104
def parse(file)
      node = parse_xml(file)
      node.xpath('p:notes/*').each do |node_child|
        case node_child.name
        when 'cSld'
          @common_slide_data = CommonSlideData.new(parent: self).parse(node_child)
        end
      end
      self
    end
1173121
private Document readDocument(InputStream in, URI file) throws TransformerConfigurationException, SAXException, IOException {
        final Document document = documentBuilder.newDocument();
        if (file != null) {
            document.setDocumentURI(file.toString());
        }

        final TransformerHandler domSerializer = saxTransformerFactory.newTransformerHandler();
        domSerializer.setResult(new DOMResult(document));
        final InputSource inputSource = new InputSource(in);
        if (file != null) {
            inputSource.setSystemId(file.toString());
        }
        validator.validate(new SAXSource(inputSource), new SAXResult(domSerializer));

        return document;
    }
927332
def parse(self, file):
        '''
        
        '''
        parser = make_parser()
        self.clear()

        class Extractor(xml.sax.ContentHandler):

            def __init__(self, parent):
                self.parent = parent

            def startElement(self, name, attrs):
                attribs = {}
                for attrname in attrs.getNames():
                    attrvalue = attrs.get(attrname)
                    attribs[attrname] = attrvalue
                self.parent.StartTag(name, attribs)

            def characters(self, text):
                self.parent.NewData(text)

            def endElement(self, name):
                self.parent.EndTag(name)
        parser.setContentHandler(Extractor(self))
        # OFFLINE MODE
        parser.setFeature(handler.feature_external_ges, False)
        fob = open(file, 'r')
        parser.parse(fob)
        return self.piece
406807
public static XElement parseXML(File file) throws XMLStreamException {
        try (InputStream in = new FileInputStream(file)) {
            return parseXML(in);
        } catch (IOException ex) {
            throw new XMLStreamException(ex);
        }
    }
1356249
private int readXMLComment(final Line firstLine, final int start)
    {
        Line line = firstLine;
        if (start + 3 < line.value.length())
        {
            if (line.value.charAt(2) == '-' && line.value.charAt(3) == '-')
            {
                int pos = start + 4;
                while (line != null)
                {
                    while (pos < line.value.length() && line.value.charAt(pos) != '-')
                    {
                        pos++;
                    }
                    if (pos == line.value.length())
                    {
                        line = line.next;
                        pos = 0;
                    }
                    else
                    {
                        if (pos + 2 < line.value.length())
                        {
                            if (line.value.charAt(pos + 1) == '-' && line.value.charAt(pos + 2) == '>')
                            {
                                this.xmlEndLine = line;
                                return pos + 3;
                            }
                        }
                        pos++;
                    }
                }
            }
        }
        return -1;
    }
487361
public synchronized Node parse(InputSource source) throws IOException,SAXException
    {
        Handler handler=new Handler();
        XMLReader reader=_parser.getXMLReader();
        reader.setContentHandler(handler);
        reader.setErrorHandler(handler);
        reader.setEntityResolver(handler);
        if(log.isDebugEnabled())
            log.debug("parsing: sid="+source.getSystemId()+",pid="+source.getPublicId());
        _parser.parse(source,handler);
        if(handler._error!=null)
            throw handler._error;
        Node doc=(Node)handler._top.get(0);
        handler.clear();
        return doc;
    }
1249622
protected void parseXml(Reader reader, XmlNamespaceDictionary namespaceDictionary)
    throws IOException, XmlPullParserException {
    this.xmlPullParser.setInput(reader);
    Xml.parseElement(this.xmlPullParser, this, namespaceDictionary, null);
  }
64896
public void parseFile(File file) throws ParserException, IOException {

        Reader reader = null;

        try {
            reader = new FileReader(file);
            nanoElement.parseFromReader(reader);
        } catch (XMLParseException e) {
            throw new ParserException(e.getMessage());
        } finally {
            if (reader != null) reader.close();
        }
    }
469079
public static Document parse(InputStream is, EntityResolver resolver) {

        try {
            DocumentBuilder parser = createParser(resolver);
            return parser.parse(is);
        }
        catch (Exception e) {
            throw new PluginException("Error parsing XML document from input stream: " + e, e);
        }
    }
1196479
public void parse(DefaultHandler dh, File f) throws SAXException, ParserConfigurationException, IOException {
        SAXParserFactory spf = SAXParserFactory.newInstance();
        SAXParser sp = spf.newSAXParser();
        XMLReader xr = sp.getXMLReader();

        xr.setContentHandler(dh);
        xr.parse(new InputSource(new FileInputStream(f)));
    }