Non-validating parsers ensure that a document meets the general rules of XML, such as that there's only one root element or that tags are properly balanced.Validating parsers perform more rigorous checks, such as making sure the document conforms to the rules laid out by its document type definition (DTD).
A parser which is nominally non-validating may or may not make use of a DTD if one is present.) For this sort of application, I generally use one or more of the various Web-based syntax checkers.(Here, I'll call these "parsers" even though they're actually Web-based interfaces which sit on top of parsers.) Good ones are: Aside from the well-formedness-vs.-validity and user-interface differences, these syntax-checkers differ in smaller ways.For example, both the Tobin and STG parsers can optionally be made namespace-aware if your application requires it. With such an avalanche of queries, you'd think our priority would be to answer as many as possible.This month, however, we tackle just one, the question of questions -- the question that nearly everyone asks at some point: Which XML parser should I use?
Let's start with one of the most basic facts about using parsers: Unless you happen to be developing XML-processing software, you can pretty much forget about this question. But it's not really a question to concern yourself with if you're just interested in browsing XML, editing it, or creating style sheets.It's like asking, "I want to buy a car and I want to make sure the wheels will stay on. The developer of the browsing application will almost certainly have made the decision for you, and you can probably override it only with difficulty (and perhaps intellectual pain).For instance, Microsoft's Internet Explorer 5.x browsers use a parser built into the file, and the Mozilla browser is built on a parser, written in C, called "expat." Nevertheless, in some cases you do need to select a parser.If you're editing XML documents by hand rather than in a GUI-based editor, you need to check them for "correctness" before putting them to use.There are two degrees of "correctness" in the XML world: well-formedness and validity.Parsers may be similarly classified as non-validating and validating.