Parsing and Lexing XML
Because XML is a well-defined language, it’s a good idea to start our XML project by reviewing the W3C XML language definition.[49] Unfortunately, the XML specification (henceforth the spec) is huge, and it’s very easy to get lost in all of the details. To make our lives easier, let’s get rid of stuff we don’t need in order to parse XML files: <!DOCTYPE..> document type definitions (DTDs), <!ENTITY..> entity declarations, and <!NOTATION..> notation declarations. Besides, handling those tags wouldn’t teach us anything beyond what we need to handle the other constructs.
We’re going to start out by building the syntactic rules for XML. The good news is that we can reuse the informal grammar rules from the spec almost verbatim ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access