An XML document is considered ‘well-formed’ if it follows the normal rules of XML. In the example below we look at validating an XML document while using DOM, SAX and St AX. On the other hand, an XML is considered valid if it follows the rules specified in the DTD or XSD. If you like Geeksfor Geeks and would like to contribute, you can also write an article using contribute.or mail your article to [email protected] After this comes closing of element indicated by This article is contributed by Kunal Sharma. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common Development * and Distribution License("CDDL") (collectively, the "License").
formatting XML with line breaks and perhaps indentation.
In contrast, St AX is a “streaming” API like SAX with minimal memory footprint regardless of data size, but its “pull” model is nearly as easy to use and understand as DOM – and St AX also features a writer.
Unless you have a compelling reason to do otherwise, you should probably use St AX by default when dealing with XML in Java.
In my opinion PULL interface is more straightforward to use and leads to smaller and more readable code responsible for handling of events.
XMLStream Reader takes care of most tasks related with parsing of XML documents like expanding entity references, unescaping special characters or handling XML namespaces.