import javax.xml.parsers.SAXParserFactory;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.ParserConfigurationException;
import org.xml.sax.SAXException;
public class TrySAX {
public static void main(String args[]) {
// Create factory object
SAXParserFactory spf = SAXParserFactory.newInstance();
spf.setNamespaceAware(true);
spf.setValidating(true);
System.out.println("Parser will "+(spf.isNamespaceAware()?"":"not ") +
"be namespace aware");
System.out.println("Parser will "+(spf.isValidating()?"":"not ") +
"validate XML");
SAXParser parser = null;
try {
parser = spf.newSAXParser();
}catch(ParserConfigurationException e){
e.printStackTrace(System.err);
System.exit(1);
} catch(SAXException e) {
e.printStackTrace(System.err);
System.exit(1);
}
System.out.println("Parser object is: "+ parser);
}
}
//谁帮助下
//感激不尽