Package javax.xml.stream

Examples of javax.xml.stream.XMLEventReader.nextEvent()


    StringWriter writer = new StringWriter();

    while ( eventReader.hasNext() )
    {
      XMLEvent event = eventReader.nextEvent();
      event.writeAsEncodedUnicode( writer );
    }

    writer.flush();
    String resultingXml = writer.toString();
View Full Code Here


    XMLInputFactory factory = XMLInputFactory.newInstance();
    XMLEventReader xmlr = factory.createXMLEventReader(new java.io.FileReader(args[0]));
   
    while(xmlr.hasNext()) {
      XMLEvent e = xmlr.nextEvent();
      System.out.println("["+
                         ElementTypeNames.getEventTypeString(e.getEventType())
                         +"]["+
                         e+"]");
    }
View Full Code Here

        InputStream stream = new ByteArrayInputStream(
            "<?xml version=\"1.0\" encoding=\"UTF-8\" ?><document>&lt;text&gt;</document>"
                .getBytes());
        XMLInputFactory factory = XMLInputFactory.newInstance();
        XMLEventReader reader = factory.createXMLEventReader(stream);
        StartDocument startdoc = (StartDocument) reader.nextEvent();
        assertEquals("UTF-8", startdoc.getCharacterEncodingScheme());
        assertEquals("1.0", startdoc.getVersion());
        assertTrue(reader.hasNext());
        XMLEvent event = reader.nextEvent();
        assertTrue(event.isStartElement());
View Full Code Here

        XMLEventReader reader = factory.createXMLEventReader(stream);
        StartDocument startdoc = (StartDocument) reader.nextEvent();
        assertEquals("UTF-8", startdoc.getCharacterEncodingScheme());
        assertEquals("1.0", startdoc.getVersion());
        assertTrue(reader.hasNext());
        XMLEvent event = reader.nextEvent();
        assertTrue(event.isStartElement());
        event = reader.nextEvent();
        assertTrue(event.isCharacters());
        String c = event.asCharacters().getData();
       
View Full Code Here

        assertEquals("UTF-8", startdoc.getCharacterEncodingScheme());
        assertEquals("1.0", startdoc.getVersion());
        assertTrue(reader.hasNext());
        XMLEvent event = reader.nextEvent();
        assertTrue(event.isStartElement());
        event = reader.nextEvent();
        assertTrue(event.isCharacters());
        String c = event.asCharacters().getData();
       
        event = reader.nextEvent();
        assertTrue(event.isCharacters());
View Full Code Here

        assertTrue(event.isStartElement());
        event = reader.nextEvent();
        assertTrue(event.isCharacters());
        String c = event.asCharacters().getData();
       
        event = reader.nextEvent();
        assertTrue(event.isCharacters());
        c+=event.asCharacters().getData();

        assertEquals("<text>",c); //FAILURE expected "<text>" but was "<text"
        event = reader.nextEvent();
View Full Code Here

        event = reader.nextEvent();
        assertTrue(event.isCharacters());
        c+=event.asCharacters().getData();

        assertEquals("<text>",c); //FAILURE expected "<text>" but was "<text"
        event = reader.nextEvent();
        assertTrue(event.isEndElement());

    }
   
    public void testXmlError2() throws Exception {
View Full Code Here

        XMLEventReader reader = factory.createXMLEventReader(stream);
        StartDocument startdoc = (StartDocument) reader.nextEvent();
        assertEquals("UTF-8", startdoc.getCharacterEncodingScheme());
        assertEquals("1.0", startdoc.getVersion());
        assertTrue(reader.hasNext());
        XMLEvent event = reader.nextEvent();
        assertTrue(event.isStartElement());
        event = reader.nextEvent();
        assertTrue(event.isCharacters());
        String c = event.asCharacters().getData();
        event = reader.nextEvent();
View Full Code Here

        assertEquals("UTF-8", startdoc.getCharacterEncodingScheme());
        assertEquals("1.0", startdoc.getVersion());
        assertTrue(reader.hasNext());
        XMLEvent event = reader.nextEvent();
        assertTrue(event.isStartElement());
        event = reader.nextEvent();
        assertTrue(event.isCharacters());
        String c = event.asCharacters().getData();
        event = reader.nextEvent();
        assertTrue(event.isCharacters());
        c+=event.asCharacters().getData();
View Full Code Here

        XMLEvent event = reader.nextEvent();
        assertTrue(event.isStartElement());
        event = reader.nextEvent();
        assertTrue(event.isCharacters());
        String c = event.asCharacters().getData();
        event = reader.nextEvent();
        assertTrue(event.isCharacters());
        c+=event.asCharacters().getData();
        event = reader.nextEvent();
        assertTrue(event.isEndElement());
       
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.