What is XML Parser
An XML parser processes and evaluates the XML code. Without a parser, the code written by you cannot be understood by the computer. Parsers come in a variety of formats and styles. They could be free-standing software, modules, classes and libraries. HTML parsing is somewhat similar. You learn more about HTML parsing and how HTML displays the data in this course.
- Where do I find a parser? Normally, you won’t need to find a parser. Modern day browsers such as Firefox,incorporate XML parsers.
- Mechanism of XML parser: Parsers convert code into something that the hardware will recognize. Objective of parsers is to transform XML into a readable code.
Kinds of XML Parsers
There are two kinds of parsers – ones that validate and the ones that don’t. Also keep in mind that you have to follow the rules. This includes root elements, nesting and a declaration statement. Parsers which validate compare a set of specific rules corresponding to each XML file. While a non-validating parser quickly checks the code to ensure that you have all the basics. However, a validating parser looks deeper.
- Standalone XML Parsers
As the name suggests, standalone parsers are separate packages that only parse XML.They are useful if you need to parse code locally or without a server package or editor. They are not so frequently used as most editing software will have a built in parser.
- XML Parsing Error
If the XML parser finds an error in the xml document during parsing, message RNX0351 is issued. From the message you can get the specific error code corresponding to the error as well as the offset in the document where the error was found.
|XML Parser Error Code||Description|
|1||The parser detected an invalid character when scanning white space outside element content.|
|2||The parser detected an invalid start of a processing instruction, element, comment, or document type declaration outside element content.|
|3||The parser detected a duplicate attribute name.|
|4||The parser detected the markup character ‘<‘ in an attribute value.|
|5||The start and end tag names of an element were different.|
|6||The parser detected an invalid character in element content.|
|7||The parser detected an invalid start of an element, comment, processing instruction, or CDATA(character Data) section in element content.|
|8||The parser detected in element content the CDATA closing character sequence ‘]]>’ without the matching opening character sequence ‘<![CDATA[‘.|
|9||The parser detected an invalid character in a comment.|
|10||The parser detected in a comment the character sequence ‘–‘ (two hyphens) not followed by ‘>’.|
|11||The parser detected an invalid character in a processing instruction data segment.|
|12||A processing instruction target name was ‘xml’ in any of the cases- lower, upper or toggle.|
|13||The parser detected an invalid digit in a hexadecimal character reference (of the form �, for example ັ).|
|14||The parser detected an invalid digit in a decimal character reference (of the form &#dddd;).|
|15||A character reference did not refer to an authorized XML character.|
|16||The parser detected an invalid character in an entity reference name.|
|17||The parser detected an invalid character in an attribute value.|
|18||The parser detected a possible invalid start of a document type declaration.|
|19||The parser detected a second document type declaration.|
|20||An element name was not specified correctly. The beginning character was not a letter, ‘_’, or ‘:’, or the parser detected an invalid character either in or following the element name.|
|21||An attribute was not specified correctly. The beginning character of the attribute name was not a letter, ‘_’, or ‘:’, or a character other than ‘=’ was detected following the attribute name, or one of the delimiters of the value was not correct, or an invalid character was detected in or following the name.|
|22||An empty element tag was not terminated by a markup language character ‘>’ following the ‘/’.|
|23||The element end tag wasn’t specified correctly. The beginning character was not a letter, ‘_’, or ‘:’, or the tag wasn’t terminated by ‘>’.|
|24||The parser detected an invalid start of a comment or CDATA section in element content.|
|25||A processing instruction target name wasn’t specified correctly. The starting character of the processing instruction target name wasn’t a letter, ‘_’, or ‘:’, or the parser detected an invalid character in or following the processing instruction target name.|
|26||A processing instruction wasn’t terminated by the closing character sequence ‘?>’.|
|27||The parser detected an invalid character following ‘&’ in a character reference or entity reference.|
|28||The version information wasn’t present in the XML declaration.|
|29||The ‘version’ in the XML declaration wasn‘t specified correctly. ‘version’ was not followed by ‘=’, or the value was not present or improperly delimited, or the value specified a bad character, or the start and end delimiters didn’t match, or the parser detected an invalid character following the version information value closing delimiter in the XML declaration.|
|30||The parser detected an invalid attribute instead of the optional encoding declaration in the XML declaration.|
|31||The encoding declaration value in the XML declaration was missing or incorrect. The value did not start with lowercase or uppercase A through Z, or ‘encoding’ wasn’t followed by ‘=’, or the value was missing or improperly delimited or it specified a bad character, or the start and end delimiters didn’t match, or the parser detected an invalid character following the closing delimiter.|
|32||The parser detected an invalid attribute instead of the optional standalone declaration in the XML declaration.|
|33||The ‘standalone’ attribute in the XML declaration wasn’t specified correctly. ‘standalone’ wasn’t followed by a ‘=’, or the value was either missing or improperly delimited, or the value was neither ‘yes’ nor ‘no’, or the value specified a bad character, or the start and end delimiters did n’t match, or the parser detected an invalid character following the closing delimiter.|
|34||The XML declaration wasn’t terminated by the proper character sequence ‘?>’, or contained an invalid attribute.|
|35||The parser detected the start of a document type declaration after the end of the root element.|
|36||The parser detected the start of an element after the end of the root element.|
|300||The parser reached the end of the concerned document before the document was complete.|
|301||The %HANDLER procedure for XML-INTO or XML-SAX returned a non-zero value, causing the XML parsing to end.|
|302||The parser doesn’t support the requested CCSID value or the first character of the XML document was not ‘<‘.|
|303||The concerned document was too large for the parser to handle. The parser tried to parse the incomplete document, but the data at the end of the document was necessary for the parsing to complete.|
|500-999||Internal error in the external parser. Report the error to your service representative.|
|10001-19999||Internal error in the parser. Report the error to your service representative.|
The error codes help you identify the exact cause of the error in your source code and fix it accordingly. Once fixed the parsing process goes on smoothly to deliver object code. To learn more about writing your own XML code, you can take this course.
Note that XML is just part of the set of languages an libraries that go into making the Internet what it is today. It would be a good idea to learn how HTML, CSS and XML come together to display pages as we see them. Udemy has a clear and simple course that shows you just how it’s done. You can take it a step further by creating your own responsive HTML page, and seeing how it shows up on different form factor devices! (and Udemy has your back – here’s a course that shows you how to create responsive HTML pages!). Go ahead, try it out!