I. Parsing an XML document
SAXParserFactory factory = Saxparserfactory.newinstance ();
Get parser
SAXParser parser = Factory.newsaxparser ();
DefaultHandler dh = new Mydefaulthandler ();
Parsing XML documents
Parser.parse ("books.xml", DH);
Ii. writing a custom processing event new Mydefaulthandler ();
/**
* If the XML file uses schema constraints <xs:element>
* * Uri:schema--targetnamespace
* * Localname--element
* * QName---xs:element
* If you do not use
* * Uri:null
* * Localname:null
* * Qname:element
*
* Attributes: A collection of all the attributes of the current element
*/
public void Startelement (string uri, String localname, String qName,
Attributes Attributes) throws Saxexception {
System.out.println ("element start" + qName + "* * *" + attributes.getvalue ("id"));
}
Third, think, can the content of Sax parsing exist, and for other programs to use?
Summary of Java XML (iv)