java - Why DocumentBuilder.parse throws SaxParserException -
the typical code snippet create dom xml below:
document dom = documentbuilderfactory.newinstance().newdocumentbuilder().parse("somefile.xml");
i wondering why parse
method throws saxexception
?
i looked code , found domparser
class parse(inputsource inputsource)
method throws exception chain.
can please me understand, why dom
creation need catch saxexception
? isn't kind of oximoron?
because internally uses sax apis.
note class reuses several classes sax api. not require implementor of underlying dom implementation use sax parser parse xml document document. merely requires implementation communicate application using these existing apis.
http://docs.oracle.com/javase/7/docs/api/javax/xml/parsers/documentbuilder.html
Comments
Post a Comment