Java Reference
In-Depth Information
} catch(SAXException | ParserConfigurationException e) {
e.printStackTrace();
System.exit(1);
}
System.out.println("\nStarting parsing of "+file+"\n");
MySAXHandler handler = new MySAXHandler();
try {
parser.parse(file, handler);
} catch(IOException | SAXException e) {
e.printStackTrace();
}
}
}
Directory "TrySAXHandler 1"
I created the circle.xml file with the following content:
<?xml version="1.0"?>
<circle diameter="40" angle="0">
<color R="255" G="0" B="0"/>
<position x="10" y="15"/>
<bounds x="10" y="15"
width="42" height="42"/>
</circle>
Directory "TrySAXHandler 1"
I saved this in my Beg Java Stuff directory, but you can put it wherever you want and adjust the
command-line argument accordingly.
On my computer the program produced the following output:
Parser will be namespace aware
Parser will validate XML
Parser object is:
com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl@159d510
Starting parsing of D:\Beg Java Stuff\circle.xml
Start document:
Start element: local name: circle qname: circle uri:
Attributes:
Name : diameter
Type : CDATA
Value: 40
Search WWH ::




Custom Search