1XML::LibXML::Parser(3)User Contributed Perl DocumentationXML::LibXML::Parser(3)
2
3
4

NAME

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

SYNOPSIS

9         use XML::LibXML 1.70;
10
11         # Parser constructor
12
13         $parser = XML::LibXML->new();
14         $parser = XML::LibXML->new(option=>value, ...);
15         $parser = XML::LibXML->new({option=>value, ...});
16
17         # Parsing XML
18
19         $dom = XML::LibXML->load_xml(
20             location => $file_or_url
21             # parser options ...
22           );
23         $dom = XML::LibXML->load_xml(
24             string => $xml_string
25             # parser options ...
26           );
27         $dom = XML::LibXML->load_xml({
28             IO => $perl_file_handle
29             # parser options ...
30           );
31         $dom = $parser->load_xml(...);
32
33         # Parsing HTML
34
35         $dom = XML::LibXML->load_html(...);
36         $dom = $parser->load_html(...);
37
38         # Parsing well-balanced XML chunks
39
40         $fragment = $parser->parse_balanced_chunk( $wbxmlstring, $encoding );
41
42         # Processing XInclude
43
44         $parser->process_xincludes( $doc );
45         $parser->processXIncludes( $doc );
46
47         # Old-style parser interfaces
48
49         $doc = $parser->parse_file( $xmlfilename );
50         $doc = $parser->parse_fh( $io_fh );
51         $doc = $parser->parse_string( $xmlstring);
52         $doc = $parser->parse_html_file( $htmlfile, \%opts );
53         $doc = $parser->parse_html_fh( $io_fh, \%opts );
54         $doc = $parser->parse_html_string( $htmlstring, \%opts );
55
56         # Push parser
57
58         $parser->parse_chunk($string, $terminate);
59         $parser->init_push();
60         $parser->push(@data);
61         $doc = $parser->finish_push( $recover );
62
63         # Set/query parser options
64
65         $parser->option_exists($name);
66         $parser->get_option($name);
67         $parser->set_option($name,$value);
68         $parser->set_options({$name=>$value,...});
69
70         # XML catalogs
71
72         $parser->load_catalog( $catalog_file );
73

PARSING

75       A XML document is read into a data structure such as a DOM tree by a
76       piece of software, called a parser. XML::LibXML currently provides four
77       different parser interfaces:
78
79       ·   A DOM Pull-Parser
80
81       ·   A DOM Push-Parser
82
83       ·   A SAX Parser
84
85       ·   A DOM based SAX Parser.
86
87   Creating a Parser Instance
88       XML::LibXML provides an OO interface to the libxml2 parser functions.
89       Thus you have to create a parser instance before you can parse any XML
90       data.
91
92       new
93             $parser = XML::LibXML->new();
94             $parser = XML::LibXML->new(option=>value, ...);
95             $parser = XML::LibXML->new({option=>value, ...});
96
97           Create a new XML and HTML parser instance. Each parser instance
98           holds default values for various parser options. Optionally, one
99           can pass a hash reference or a list of option => value pairs to set
100           a different default set of options.  Unless specified otherwise,
101           the options "load_ext_dtd", "expand_entities", and "huge" are set
102           to 1. See "Parser Options" for a list of libxml2 parser's options.
103
104   DOM Parser
105       One of the common parser interfaces of XML::LibXML is the DOM parser.
106       This parser reads XML data into a DOM like data structure, so each tag
107       can get accessed and transformed.
108
109       XML::LibXML's DOM parser is not only capable to parse XML data, but
110       also (strict) HTML files. There are three ways to parse documents - as
111       a string, as a Perl filehandle, or as a filename/URL. The return value
112       from each is a XML::LibXML::Document object, which is a DOM object.
113
114       All of the functions listed below will throw an exception if the
115       document is invalid. To prevent this causing your program exiting, wrap
116       the call in an eval{} block
117
118       load_xml
119             $dom = XML::LibXML->load_xml(
120                 location => $file_or_url
121                 # parser options ...
122               );
123             $dom = XML::LibXML->load_xml(
124                 string => $xml_string
125                 # parser options ...
126               );
127             $dom = XML::LibXML->load_xml({
128                 IO => $perl_file_handle
129                 # parser options ...
130               );
131             $dom = $parser->load_xml(...);
132
133           This function is available since XML::LibXML 1.70. It provides easy
134           to use interface to the XML parser that parses given file (or URL),
135           string, or input stream to a DOM tree. The arguments can be passed
136           in a HASH reference or as name => value pairs. The function can be
137           called as a class method or an object method. In both cases it
138           internally creates a new parser instance passing the specified
139           parser options; if called as an object method, it clones the
140           original parser (preserving its settings) and additionally applies
141           the specified options to the new parser. See the constructor "new"
142           and "Parser Options" for more information.
143
144       load_xml
145             $dom = XML::LibXML->load_html(...);
146             $dom = $parser->load_html(...);
147
148           This function is available since XML::LibXML 1.70. It has the same
149           usage as "load_xml", providing interface to the HTML parser. See
150           "load_xml" for more information.
151
152           Parsing HTML may cause problems, especially if the ampersand ('&')
153           is used.  This is a common problem if HTML code is parsed that
154           contains links to CGI-scripts. Such links cause the parser to throw
155           errors. In such cases libxml2 still parses the entire document as
156           there was no error, but the error causes XML::LibXML to stop the
157           parsing process. However, the document is not lost.  Such HTML
158           documents should be parsed using the recover flag. By default
159           recovering is deactivated.
160
161           The functions described above are implemented to parse well formed
162           documents.  In some cases a program gets well balanced XML instead
163           of well formed documents (e.g. a XML fragment from a Database).
164           With XML::LibXML it is not required to wrap such fragments in the
165           code, because XML::LibXML is capable even to parse well balanced
166           XML fragments.
167
168           parse_balanced_chunk
169                 $fragment = $parser->parse_balanced_chunk( $wbxmlstring, $encoding );
170
171               This function parses a well balanced XML string into a
172               XML::LibXML::DocumentFragment. The first arguments contains the
173               input string, the optional second argument can be used to
174               specify character encoding of the input (UTF-8 is assumed by
175               default).
176
177           parse_xml_chunk
178               This is the old name of parse_balanced_chunk(). Because it may
179               causes confusion with the push parser interface, this function
180               should not be used anymore.
181
182           By default XML::LibXML does not process XInclude tags within a XML
183           Document (see options section below). XML::LibXML allows to post
184           process a document to expand XInclude tags.
185
186           process_xincludes
187                 $parser->process_xincludes( $doc );
188
189               After a document is parsed into a DOM structure, you may want
190               to expand the documents XInclude tags. This function processes
191               the given document structure and expands all XInclude tags (or
192               throws an error) by using the flags and callbacks of the given
193               parser instance.
194
195               Note that the resulting Tree contains some extra nodes (of type
196               XML_XINCLUDE_START and XML_XINCLUDE_END) after successfully
197               processing the document. These nodes indicate where data was
198               included into the original tree.  if the document is
199               serialized, these extra nodes will not show up.
200
201               Remember: A Document with processed XIncludes differs from the
202               original document after serialization, because the original
203               XInclude tags will not get restored!
204
205               If the parser flag "expand_xincludes" is set to 1, you need not
206               to post process the parsed document.
207
208           processXIncludes
209                 $parser->processXIncludes( $doc );
210
211               This is an alias to process_xincludes, but through a JAVA like
212               function name.
213
214           parse_file
215                 $doc = $parser->parse_file( $xmlfilename );
216
217               This function parses an XML document from a file or network;
218               $xmlfilename can be either a filename or an URL. Note that for
219               parsing files, this function is the fastest choice, about 6-8
220               times faster then parse_fh().
221
222           parse_fh
223                 $doc = $parser->parse_fh( $io_fh );
224
225               parse_fh() parses a IOREF or a subclass of IO::Handle.
226
227               Because the data comes from an open handle, libxml2's parser
228               does not know about the base URI of the document. To set the
229               base URI one should use parse_fh() as follows:
230
231                 my $doc = $parser->parse_fh( $io_fh, $baseuri );
232
233           parse_string
234                 $doc = $parser->parse_string( $xmlstring);
235
236               This function is similar to parse_fh(), but it parses a XML
237               document that is available as a single string in memory. Again,
238               you can pass an optional base URI to the function.
239
240                 my $doc = $parser->parse_string( $xmlstring, $baseuri );
241
242           parse_html_file
243                 $doc = $parser->parse_html_file( $htmlfile, \%opts );
244
245               Similar to parse_file() but parses HTML (strict) documents;
246               $htmlfile can be filename or URL.
247
248               An optional second argument can be used to pass some options to
249               the HTML parser as a HASH reference. See options labeled with
250               HTML in "Parser Options".
251
252           parse_html_fh
253                 $doc = $parser->parse_html_fh( $io_fh, \%opts );
254
255               Similar to parse_fh() but parses HTML (strict) streams.
256
257               An optional second argument can be used to pass some options to
258               the HTML parser as a HASH reference. See options labeled with
259               HTML in "Parser Options".
260
261               Note: encoding option may not work correctly with this function
262               in libxml2 < 2.6.27 if the HTML file declares charset using a
263               META tag.
264
265           parse_html_string
266                 $doc = $parser->parse_html_string( $htmlstring, \%opts );
267
268               Similar to parse_string() but parses HTML (strict) strings.
269
270               An optional second argument can be used to pass some options to
271               the HTML parser as a HASH reference. See options labeled with
272               HTML in "Parser Options".
273
274   Push Parser
275       XML::LibXML provides a push parser interface. Rather than pulling the
276       data from a given source the push parser waits for the data to be
277       pushed into it.
278
279       This allows one to parse large documents without waiting for the parser
280       to finish. The interface is especially useful if a program needs to
281       pre-process the incoming pieces of XML (e.g. to detect document
282       boundaries).
283
284       While XML::LibXML parse_*() functions force the data to be a well-
285       formed XML, the push parser will take any arbitrary string that
286       contains some XML data. The only requirement is that all the pushed
287       strings are together a well formed document. With the push parser
288       interface a program can interrupt the parsing process as required,
289       where the parse_*() functions give not enough flexibility.
290
291       Different to the pull parser implemented in parse_fh() or parse_file(),
292       the push parser is not able to find out about the documents end itself.
293       Thus the calling program needs to indicate explicitly when the parsing
294       is done.
295
296       In XML::LibXML this is done by a single function:
297
298       parse_chunk
299             $parser->parse_chunk($string, $terminate);
300
301           parse_chunk() tries to parse a given chunk of data, which isn't
302           necessarily well balanced data. The function takes two parameters:
303           The chunk of data as a string and optional a termination flag. If
304           the termination flag is set to a true value (e.g. 1), the parsing
305           will be stopped and the resulting document will be returned as the
306           following example describes:
307
308             my $parser = XML::LibXML->new;
309             for my $string ( "<", "foo", ' bar="hello world"', "/>") {
310                  $parser->parse_chunk( $string );
311             }
312             my $doc = $parser->parse_chunk("", 1); # terminate the parsing
313
314       Internally XML::LibXML provides three functions that control the push
315       parser process:
316
317       init_push
318             $parser->init_push();
319
320           Initializes the push parser.
321
322       push
323             $parser->push(@data);
324
325           This function pushes the data stored inside the array to libxml2's
326           parser. Each entry in @data must be a normal scalar! This method
327           can be called repeatedly.
328
329       finish_push
330             $doc = $parser->finish_push( $recover );
331
332           This function returns the result of the parsing process. If this
333           function is called without a parameter it will complain about non
334           well-formed documents. If $restore is 1, the push parser can be
335           used to restore broken or non well formed (XML) documents as the
336           following example shows:
337
338             eval {
339                 $parser->push( "<foo>", "bar" );
340                 $doc = $parser->finish_push();    # will report broken XML
341             };
342             if ( $@ ) {
343                # ...
344             }
345
346           This can be annoying if the closing tag is missed by accident. The
347           following code will restore the document:
348
349             eval {
350                 $parser->push( "<foo>", "bar" );
351                 $doc = $parser->finish_push(1);   # will return the data parsed
352                                                   # unless an error happened
353             };
354
355             print $doc->toString(); # returns "<foo>bar</foo>"
356
357           Of course finish_push() will return nothing if there was no data
358           pushed to the parser before.
359
360   Pull Parser (Reader)
361       XML::LibXML also provides a pull-parser interface similar to the
362       XmlReader interface in .NET. This interface is almost streaming, and is
363       usually faster and simpler to use than SAX. See XML::LibXML::Reader.
364
365   Direct SAX Parser
366       XML::LibXML provides a direct SAX parser in the XML::LibXML::SAX
367       module.
368
369   DOM based SAX Parser
370       XML::LibXML also provides a DOM based SAX parser. The SAX parser is
371       defined in the module XML::LibXML::SAX::Parser. As it is not a stream
372       based parser, it parses documents into a DOM and traverses the DOM tree
373       instead.
374
375       The API of this parser is exactly the same as any other Perl SAX2
376       parser. See XML::SAX::Intro for details.
377
378       Aside from the regular parsing methods, you can access the DOM tree
379       traverser directly, using the generate() method:
380
381         my $doc = build_yourself_a_document();
382         my $saxparser = $XML::LibXML::SAX::Parser->new( ... );
383         $parser->generate( $doc );
384
385       This is useful for serializing DOM trees, for example that you might
386       have done prior processing on, or that you have as a result of XSLT
387       processing.
388
389       WARNING
390
391       This is NOT a streaming SAX parser. As I said above, this parser reads
392       the entire document into a DOM and serialises it. Some people couldn't
393       read that in the paragraph above so I've added this warning. If you
394       want a streaming SAX parser look at the XML::LibXML::SAX man page
395

SERIALIZATION

397       XML::LibXML provides some functions to serialize nodes and documents.
398       The serialization functions are described on the XML::LibXML::Node
399       manpage or the XML::LibXML::Document manpage. XML::LibXML checks three
400       global flags that alter the serialization process:
401
402       ·   skipXMLDeclaration
403
404       ·   skipDTD
405
406       ·   setTagCompression
407
408       of that three functions only setTagCompression is available for all
409       serialization functions.
410
411       Because XML::LibXML does these flags not itself, one has to define them
412       locally as the following example shows:
413
414         local $XML::LibXML::skipXMLDeclaration = 1;
415         local $XML::LibXML::skipDTD = 1;
416         local $XML::LibXML::setTagCompression = 1;
417
418       If skipXMLDeclaration is defined and not '0', the XML declaration is
419       omitted during serialization.
420
421       If skipDTD is defined and not '0', an existing DTD would not be
422       serialized with the document.
423
424       If setTagCompression is defined and not '0' empty tags are displayed as
425       open and closing tags rather than the shortcut. For example the empty
426       tag foo will be rendered as <foo></foo> rather than <foo/>.
427

PARSER OPTIONS

429       Handling of libxml2 parser options has been unified and improved in
430       XML::LibXML 1.70. You can now set default options for a particular
431       parser instance by passing them to the constructor as
432       "XML::LibXML->new({name=>value, ...})" or
433       "XML::LibXML->new(name=>value,...)". The options can be queried and
434       changed using the following methods (pre-1.70 interfaces such as
435       "$parser->load_ext_dtd(0)" also exist, see below):
436
437       option_exists
438             $parser->option_exists($name);
439
440           Returns 1 if the current XML::LibXML version supports the option
441           $name, otherwise returns 0 (note that this does not necessarily
442           mean that the option is supported by the underlying libxml2
443           library).
444
445       get_option
446             $parser->get_option($name);
447
448           Returns the current value of the parser option $name.
449
450       set_option
451             $parser->set_option($name,$value);
452
453           Sets option $name to value $value.
454
455       set_options
456             $parser->set_options({$name=>$value,...});
457
458           Sets multiple parsing options at once.
459
460       IMPORTANT NOTE: This documentation reflects the parser flags available
461       in libxml2 2.7.3. Some options have no effect if an older version of
462       libxml2 is used.
463
464       Each of the flags listed below is labeled labeled
465
466       /parser/
467           if it can be used with a "XML::LibXML" parser object (i.e. passed
468           to "XML::LibXML->new", "XML::LibXML->set_option", etc.)
469
470       /html/
471           if it can be used passed to the "parse_html_*" methods
472
473       /reader/
474           if it can be used with the "XML::LibXML::Reader".
475
476       Unless specified otherwise, the default for boolean valued options is 0
477       (false).
478
479       The available options are:
480
481       URI /parser, html, reader/
482
483           In case of parsing strings or file handles, XML::LibXML doesn't
484           know about the base uri of the document. To make relative
485           references such as XIncludes work, one has to set a base URI, that
486           is then used for the parsed document.
487
488       line_numbers
489           /parser, html, reader/
490
491           If this option is activated, libxml2 will store the line number of
492           each element node in the parsed document. The line number can be
493           obtained using the "line_number()" method of the
494           "XML::LibXML::Node" class (for non-element nodes this may report
495           the line number of the containing element). The line numbers are
496           also used for reporting positions of validation errors.
497
498           IMPORTANT: Due to limitations in the libxml2 library line numbers
499           greater than 65535 will be returned as 65535. Unfortunatelly, this
500           is a long and sad story, please see
501           <http://bugzilla.gnome.org/show_bug.cgi?id=325533> for more
502           details.
503
504       encoding
505           /html/
506
507           character encoding of the input
508
509       recover
510           /parser, html, reader/
511
512           recover from errors; possible values are 0, 1, and 2
513
514           A true value turns on recovery mode which allows one to parse
515           broken XML or HTML data. The recovery mode allows the parser to
516           return the successfully parsed portion of the input document. This
517           is useful for almost well-formed documents, where for example a
518           closing tag is missing somewhere. Still, XML::LibXML will only
519           parse until the first fatal (non-recoverable) error occurs,
520           reporting recoverable parsing errors as warnings. To suppress even
521           these warnings, use recover=>2.
522
523           Note that validation is switched off automatically in recovery
524           mode.
525
526       expand_entities
527           /parser, reader/
528
529           substitute entities; possible values are 0 and 1; default is 1
530
531           Note that although this flag disables entity substitution, it does
532           not prevent the parser from loading external entities; when
533           substitution of an external entity is disabled, the entity will be
534           represented in the document tree by a XML_ENTITY_REF_NODE node
535           whose subtree will be the content obtained by parsing the external
536           resource; Although this is level of nesting is visible from the DOM
537           it is transparent to XPath data model, so it is possible to match
538           nodes in an unexpanded entity by the same XPath expression as if
539           the entity was expanded. See also ext_ent_handler.
540
541       ext_ent_handler
542           /parser/
543
544           Provide a custom external entity handler to be used when
545           expand_entities is set to 1. Possible value is a subroutine
546           reference.
547
548           This feature does not work properly in libxml2 < 2.6.27!
549
550           The subroutine provided is called whenever the parser needs to
551           retrieve the content of an external entity. It is called with two
552           arguments: the system ID (URI) and the public ID. The value
553           returned by the subroutine is parsed as the content of the entity.
554
555           This method can be used to completely disable entity loading, e.g.
556           to prevent exploits of the type described at
557           (<http://searchsecuritychannel.techtarget.com/generic/0,295582,sid97_gci1304703,00.html>),
558           where a service is tricked to expose its private data by letting it
559           parse a remote file (RSS feed) that contains an entity reference to
560           a local file (e.g. "/etc/fstab").
561
562           A more granular solution to this problem, however, is provided by
563           custom URL resolvers, as in
564
565             my $c = XML::LibXML::InputCallback->new();
566             sub match {   # accept file:/ URIs except for XML catalogs in /etc/xml/
567               my ($uri) = @_;
568               return ($uri=~m{^file:/}
569                       and $uri !~ m{^file:///etc/xml/})
570                      ? 1 : 0;
571             }
572             $c->register_callbacks([ \&match, sub{}, sub{}, sub{} ]);
573             $parser->input_callbacks($c);
574
575       load_ext_dtd
576           /parser, reader/
577
578           load the external DTD subset while parsing; possible values are 0
579           and 1. Unless specified, XML::LibXML sets this option to 1.
580
581           This flag is also required for DTD Validation, to provide complete
582           attribute, and to expand entities, regardless if the document has
583           an internal subset. Thus switching off external DTD loading, will
584           disable entity expansion, validation, and complete attributes on
585           internal subsets as well.
586
587       complete_attributes
588           /parser, reader/
589
590           create default DTD attributes; possible values are 0 and 1
591
592       validation
593           /parser, reader/
594
595           validate with the DTD; possible values are 0 and 1
596
597       suppress_errors
598           /parser, html, reader/
599
600           suppress error reports; possible values are 0 and 1
601
602       suppress_warnings
603           /parser, html, reader/
604
605           suppress warning reports; possible values are 0 and 1
606
607       pedantic_parser
608           /parser, html, reader/
609
610           pedantic error reporting; possible values are 0 and 1
611
612       no_blanks
613           /parser, html, reader/
614
615           remove blank nodes; possible values are 0 and 1
616
617       expand_xinclude or xinclude
618           /parser, reader/
619
620           Implement XInclude substitution; possible values are 0 and 1
621
622           Expands XIinclude tags immediately while parsing the document. Note
623           that the parser will use the URI resolvers installed via
624           "XML::LibXML::InputCallback" to parse the included document (if
625           any).
626
627       no_xinclude_nodes
628           /parser, reader/
629
630           do not generate XINCLUDE START/END nodes; possible values are 0 and
631           1
632
633       no_network
634           /parser, html, reader/
635
636           Forbid network access; possible values are 0 and 1
637
638           If set to true, all attempts to fetch non-local resources (such as
639           DTD or external entities) will fail (unless custom callbacks are
640           defined).
641
642           It may be necessary to use the flag "recover" for processing
643           documents requiring such resources while networking is off.
644
645       clean_namespaces
646           /parser, reader/
647
648           remove redundant namespaces declarations during parsing; possible
649           values are 0 and 1.
650
651       no_cdata
652           /parser, html, reader/
653
654           merge CDATA as text nodes; possible values are 0 and 1
655
656       no_basefix
657           /parser, reader/
658
659           not fixup XINCLUDE xml#base URIS; possible values are 0 and 1
660
661       huge
662           /parser, html, reader/
663
664           relax any hardcoded limit from the parser; possible values are 0
665           and 1. Unless specified, XML::LibXML sets this option to 1.
666
667       gdome
668           /parser/
669
670           THIS OPTION IS EXPERIMENTAL!
671
672           Although quite powerful, XML:LibXML's DOM implementation is
673           incomplete with respect to the DOM level 2 or level 3
674           specifications. XML::GDOME is based on libxml2 as well and and
675           provides a rather complete DOM implementation by wrapping libgdome.
676           This flag allows you to make use of XML::LibXML's full parser
677           options and XML::GDOME's DOM implementation at the same time.
678
679           To make use of this function, one has to install libgdome and
680           configure XML::LibXML to use this library. For this you need to
681           rebuild XML::LibXML!
682
683           Note: this feature was not seriously tested in recent XML::LibXML
684           releases.
685
686       For compatibility with XML::LibXML versions prior to 1.70, the
687       following methods are also supported for querying and setting the
688       corresponding parser options (if called without arguments, the methods
689       return the current value of the corresponding parser options; with an
690       argument sets the option to a given value):
691
692         $parser->validation();
693         $parser->recover();
694         $parser->pedantic_parser();
695         $parser->line_numbers();
696         $parser->load_ext_dtd();
697         $parser->complete_attributes();
698         $parser->expand_xinclude();
699         $parser->gdome_dom();
700         $parser->clean_namespaces();
701         $parser->no_network();
702
703       The following obsolete methods trigger parser options in some special
704       way:
705
706       recover_silently
707             $parser->recover_silently(1);;
708
709           If called without an argument, returns true if the current value of
710           the "recover" parser option is 2 and returns false otherwise. With
711           a true argument sets the "recover" parser option to 2; with a false
712           argument sets the "recover" parser option to 0.
713
714       expand_entities
715             $parser->expand_entities(0);
716
717           Get/set the "expand_entities" option. If called with a true
718           argument, also turns the "load_ext_dtd" option to 1.
719
720       keep_blanks
721             $parser->keep_blanks(0);
722
723           This is actually an oposite of the "no_blanks" parser option. If
724           used without an argument retrieves negated value of "no_blanks". If
725           used with an argument sets "no_blanks" to the oposite value.
726
727       base_uri
728             $parser->base_uri( $your_base_uri );
729
730           Get/set the "URI" option.
731

XML CATALOGS

733       "libxml2" supports XML catalogs. Catalogs are used to map remote
734       resources to their local copies. Using catalogs can speed up parsing
735       processes if many external resources from remote addresses are loaded
736       into the parsed documents (such as DTDs or XIncludes).
737
738       Note that libxml2 has a global pool of loaded catalogs, so if you apply
739       the method "load_catalog" to one parser instance, all parser instances
740       will start using the catalog (in addition to other previously loaded
741       catalogs).
742
743       Note also that catalogs are not used when a custom external entity
744       handler is specified. At the current state it is not possible to make
745       use of both types of resolving systems at the same time.
746
747       load_catalog
748             $parser->load_catalog( $catalog_file );
749
750           Loads the XML catalog file $catalog_file.
751

ERROR REPORTING

753       XML::LibXML throws exceptions during parsing, validation or XPath
754       processing (and some other occasions). These errors can be caught by
755       using eval blocks. The error is stored in $@. There are two
756       implementations: the old one throws $@ which is just a message string,
757       in the new one $@ is an object from the class XML::LibXML::Error; this
758       class overrides the operator "" so that when printed, the object
759       flattens to the usual error message.
760
761       XML::LibXML throws errors as they occur. This is a very common
762       misunderstanding in the use of XML::LibXML. If the eval is omitted,
763       XML::LibXML will always halt your script by "croaking" (see Carp man
764       page for details).
765
766       Also note that an increasing number of functions throw errors if bad
767       data is passed as arguments. If you cannot assure valid data passed to
768       XML::LibXML you should eval these functions.
769
770       Note: since version 1.59, get_last_error() is no longer available in
771       XML::LibXML for thread-safety reasons.
772

AUTHORS

774       Matt Sergeant, Christian Glahn, Petr Pajas
775

VERSION

777       1.70
778
780       2001-2007, AxKit.com Ltd.
781
782       2002-2006, Christian Glahn.
783
784       2006-2009, Petr Pajas.
785
786
787
788perl v5.12.0                      2009-10-07            XML::LibXML::Parser(3)
Impressum