Deal with errors in XML parsing

From: IBM developerWorks Worldwide  read times: 325


Provided by yangyi at 2008-07-27 20:06:27


Level: Intermediate

Brett D. McLaughlin, Sr. (brett@newInstance.com), Author and Editor, O'Reilly Media, Inc.

22 Jul 2008

With the ease of XML parsing in the newer Java™ language APIs, from JAXP to JAXB to JAX-WS, XML parsing has become foundational to Java programming. But with the abstractions and higher-level APIs comes an apparent loss of control over the fine-grained interactions between a parser and your XML data. This typically leads to more errors or worse, a complete halt of parsing when even the smallest problem arises. Fortunately, the Simple API for XML (SAX) still provides an easy-to-use means of dealing with errors and you can access that mechanism even when you don't use SAX directly.

XML parses the newer Java language APIs—JAXP, JAXB, JAX-WS, and more—so easily that XML parsing is now a fundamental aspect of Java programming; potential problems arise when abstractions in the higher-level APIs cause a loss of fine-grained control between parser and data interactions. In this article, I'll show you how the Simple API for XML (SAX) delivers an easy-to-use vehicle to deal with those errors, one you can use even when you're not using SAX directly.

A crashing program is not error handling

......

Please access the below link to view the full content.

Original link: http://www.ibm.com/developerwork...