0
  #   ˆl–Ðz¾”*h¥ ² Aq Ü TÅ£¿„À¿ÂÁ ?÷     =head1 NAME

XML::LibXML::Parser - Parsing XML Data with XML::LibXML

=head1 SYNOPSIS



  use XML::LibXML 1.70;

  # Parser constructor

  $parser = XML::LibXML->new();
  $parser = XML::LibXML->new(option=>value, ...);
  $parser = XML::LibXML->new({option=>value, ...});

  # Parsing XML

  $dom = XML::LibXML->load_xml(
      location => $file_or_url
      # parser options ...
    );
  $dom = XML::LibXML->load_xml(
      string => $xml_string
      # parser options ...
    );
  $dom = XML::LibXML->load_xml(
      string => (\$xml_string)
      # parser options ...
    );
  $dom = XML::LibXML->load_xml({
      IO => $perl_file_handle
      # parser options ...
    );
  $dom = $parser->load_xml(...);

  # Parsing HTML

  $dom = XML::LibXML->load_html(...);
  $dom = $parser->load_html(...);

  # Parsing well-balanced XML chunks

  $fragment = $parser->parse_balanced_chunk( $wbxmlstring, $encoding );

  # Processing XInclude

  $parser->process_xincludes( $doc );
  $parser->processXIncludes( $doc );

  # Old-style parser interfaces

  $doc = $parser->parse_file( $xmlfilename );
  $doc = $parser->parse_fh( $io_fh );
  $doc = $parser->parse_string( $xmlstring);
  $doc = $parser->parse_html_file( $htmlfile, \%opts );
  $doc = $parser->parse_html_fh( $io_fh, \%opts );
  $doc = $parser->parse_html_string( $htmlstring, \%opts );

  # Push parser

  $parser->parse_chunk($string, $terminate);
  $parser->init_push();
  $parser->push(@data);
  $doc = $parser->finish_push( $recover );

  # Set/query parser options

  $parser->option_exists($name);
  $parser->get_option($name);
  $parser->set_option($name,$value);
  $parser->set_options({$name=>$value,...});

  # XML catalogs

  $parser->load_catalog( $catalog_file );

=head1 PARSING

An XML document is read into a data structure such as a DOM tree by a piece of
software, called a parser. XML::LibXML currently provides four different parser
interfaces:


=over 4

=item *

A DOM Pull-Parser



=item *

A DOM Push-Parser



=item *

A SAX Parser



=item *

A DOM based SAX Parser.



=back


=head2 Creating a Parser Instance

XML::LibXML provides an OO interface to the libxml2 parser functions. Thus you
have to create a parser instance before you can parse any XML data.

=over 4

=item new


  $parser = XML::LibXML->new();
  $parser = XML::LibXML->new(option=>value, ...);
  $parser = XML::LibXML->new({option=>value, ...});

Create a new XML and HTML parser instance. Each parser instance holds default
values for various parser options. Optionally, one can pass a hash reference or
a list of option => value pairs to set a different default set of options.
Unless specified otherwise, the options C<<<<<< load_ext_dtd >>>>>>, and C<<<<<< expand_entities >>>>>> are set to 1. See L<<<<<< Parser Options >>>>>> for a list of libxml2 parser's options.



=back


=head2 DOM Parser

One of the common parser interfaces of XML::LibXML is the DOM parser. This
parser reads XML data into a DOM like data structure, so each tag can get
accessed and transformed.

XML::LibXML's DOM parser is not only capable to parse XML data, but also
(strict) HTML files. There are three ways to parse documents - as a string, as
a Perl filehandle, or as a filename/URL. The return value from each is a L<<<<<< XML::LibXML::Document >>>>>> object, which is a DOM object.

All of the functions listed below will throw an exception if the document is
invalid. To prevent this causing your program exiting, wrap the call in an
eval{} block

=over 4

=item load_xml


  $dom = XML::LibXML->load_xml(
      location => $file_or_url
      # parser options ...
    );
  $dom = XML::LibXML->load_xml(
      string => $xml_string
      # parser options ...
    );
  $dom = XML::LibXML->load_xml(
      string => (\$xml_string)
      # parser options ...
    );
  $dom = XML::LibXML->load_xml({
      IO => $perl_file_handle
      # parser options ...
    );
  $dom = $parser->load_xml(...);


This function is available since XML::LibXML 1.70. It provides easy to use
interface to the XML parser th