Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamReader;
import javax.xml.transform.stream.StreamSource;

public class Main {
    public static void main(String[] args) throws Exception {
        XMLInputFactory xif = XMLInputFactory.newFactory();
        StreamSource xmlSource = new StreamSource("src/forum19559825/input.xml");
        XMLStreamReader xsr = xif.createXMLStreamReader(xmlSource);
        positionXMLStreamReaderAtAnyElement(xsr);
        processAnyElement(xsr);
    }

    private static void positionXMLStreamReaderAtAnyElement(XMLStreamReader xsr) throws Exception {
        while (xsr.hasNext()) {
            if (xsr.getEventType() == XMLStreamReader.START_ELEMENT && "ANY-ELEMENT".equals(xsr.getLocalName())) {
                break;
            }
            xsr.next();
        }
    }

    private static void processAnyElement(XMLStreamReader xmlStreamReaderAtAnyElement) {
        System.out.println("FOUND IT");
    }
}