An XML parser


  use Whatpm::XML::Parser;
  use Message::DOM::DOMImplementation;
  $parser = Whatpm::XML::Parser->new;
  $dom = Message::DOM::DOMImplementation->new;
  $doc = $dom->create_document;
  $parser->parse_char_string ($chars => $doc);

  ## Or, just use DOM attribute:
  $doc->inner_html ($chars);


The Whatpm::XML::Parser module is an implementation of the XML parser. The parser is not Draconian - the parser does not holt on well-formedness errors. It implements a variant of XML5 proposal, which defines error handling for ill-formed XML documents.


It is recommended to use standard DOM interface, such as inner_html method of the Document object, to parse an XML string, where possible. The Whatpm::XML::Parser module, which, in fact, is used to implement the inner_html method, offers more control on how parser behaves, which would not be useful unless you are writing a complex user agent such as browser or validator.

The Whatpm::XML::Parser module provides following methods:

$parser = Whatpm::XML::Parser->new

Create a new parser.

$parser->parse_char_string ($chars => $doc)

Parse a string of characters (i.e. a possibly utf8-flagged string) as XML and construct the DOM tree.

The first argument to the method must be a string to parse. It may or may not be a valid or well-formed XML document.

The second argument to the method must be a DOM Document object (Message::DOM::Document). Any child nodes of the document is first removed by the parser.

$code = $parser->onerror
$parser->onerror ($new_code)

Get or set the error handler for the parser. Any parse error, as well as warning and information, is reported to the handler. See Whatpm::Errors for more information.

Parsed document structure is reflected to the Document object specified as an argument to parse methods.


Message::DOM::Document, Message::DOM::Element.





XML 1.0 <>.

XML 1.1 <>.

Namespaces in XML 1.0 <>.

Namespaces in XML 1.1 <>.

XML Information Set <>.

DOM Level 3 Core - Infoset Mapping <>.

XML5. See <> for references.


HTML Living Standard -Parsing XHTML documents <>.


manakai's XML Conformance Checking <>.


DOM Document Type Definition Module <>.


manakai DOM Extensions <>.


Wakaba <>.


Copyright 2007-2012 Wakaba <>.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.