Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;

import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler;

public class Main {
    public static void main(String args[]) throws Exception {
        SAXParserFactory factory = SAXParserFactory.newInstance();
        SAXParser saxParser = factory.newSAXParser();
        DefaultHandler handler = new DefaultHandler() {
            public void startElement(String uri, String localName, String qName, Attributes attributes)
                    throws SAXException {
                System.out.println(qName);
            }

            public void characters(char ch[], int start, int length) throws SAXException {
                System.out.println(new String(ch, start, length));
            }
        };

        saxParser.parse(args[0], handler);
    }
}