403Webshell
Server IP : 103.119.228.120  /  Your IP : 18.226.17.251
Web Server : Apache
System : Linux v8.techscape8.com 3.10.0-1160.119.1.el7.tuxcare.els2.x86_64 #1 SMP Mon Jul 15 12:09:18 UTC 2024 x86_64
User : nobody ( 99)
PHP Version : 5.6.40
Disable Function : shell_exec,symlink,system,exec,proc_get_status,proc_nice,proc_terminate,define_syslog_variables,syslog,openlog,closelog,escapeshellcmd,passthru,ocinum cols,ini_alter,leak,listen,chgrp,apache_note,apache_setenv,debugger_on,debugger_off,ftp_exec,dl,dll,myshellexec,proc_open,socket_bind,proc_close,escapeshellarg,parse_ini_filepopen,fpassthru,exec,passthru,escapeshellarg,escapeshellcmd,proc_close,proc_open,ini_alter,popen,show_source,proc_nice,proc_terminate,proc_get_status,proc_close,pfsockopen,leak,apache_child_terminate,posix_kill,posix_mkfifo,posix_setpgid,posix_setsid,posix_setuid,dl,symlink,shell_exec,system,dl,passthru,escapeshellarg,escapeshellcmd,myshellexec,c99_buff_prepare,c99_sess_put,fpassthru,getdisfunc,fx29exec,fx29exec2,is_windows,disp_freespace,fx29sh_getupdate,fx29_buff_prepare,fx29_sess_put,fx29shexit,fx29fsearch,fx29ftpbrutecheck,fx29sh_tools,fx29sh_about,milw0rm,imagez,sh_name,myshellexec,checkproxyhost,dosyayicek,c99_buff_prepare,c99_sess_put,c99getsource,c99sh_getupdate,c99fsearch,c99shexit,view_perms,posix_getpwuid,posix_getgrgid,posix_kill,parse_perms,parsesort,view_perms_color,set_encoder_input,ls_setcheckboxall,ls_reverse_all,rsg_read,rsg_glob,selfURL,dispsecinfo,unix2DosTime,addFile,system,get_users,view_size,DirFiles,DirFilesWide,DirPrintHTMLHeaders,GetFilesTotal,GetTitles,GetTimeTotal,GetMatchesCount,GetFileMatchesCount,GetResultFiles,fs_copy_dir,fs_copy_obj,fs_move_dir,fs_move_obj,fs_rmdir,SearchText,getmicrotime
MySQL : ON |  cURL : ON |  WGET : ON |  Perl : ON |  Python : ON |  Sudo : ON |  Pkexec : ON
Directory :  /usr/local/ssl/local/ssl/local/ssl/local/ssl/local/ssl/local/share/man/man3/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : /usr/local/ssl/local/ssl/local/ssl/local/ssl/local/ssl/local/share/man/man3/XML::LibXML::Parser.3pm
.\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28)
.\"
.\" Standard preamble:
.\" ========================================================================
.de Sp \" Vertical space (when we can't use .PP)
.if t .sp .5v
.if n .sp
..
.de Vb \" Begin verbatim text
.ft CW
.nf
.ne \\$1
..
.de Ve \" End verbatim text
.ft R
.fi
..
.\" Set up some character translations and predefined strings.  \*(-- will
.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
.\" double quote, and \*(R" will give a right double quote.  \*(C+ will
.\" give a nicer C++.  Capital omega is used to do unbreakable dashes and
.\" therefore won't be available.  \*(C` and \*(C' expand to `' in nroff,
.\" nothing in troff, for use with C<>.
.tr \(*W-
.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
.ie n \{\
.    ds -- \(*W-
.    ds PI pi
.    if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
.    if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\"  diablo 12 pitch
.    ds L" ""
.    ds R" ""
.    ds C` ""
.    ds C' ""
'br\}
.el\{\
.    ds -- \|\(em\|
.    ds PI \(*p
.    ds L" ``
.    ds R" ''
.    ds C`
.    ds C'
'br\}
.\"
.\" Escape single quotes in literal strings from groff's Unicode transform.
.ie \n(.g .ds Aq \(aq
.el       .ds Aq '
.\"
.\" If the F register is turned on, we'll generate index entries on stderr for
.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
.\" entries marked with X<> in POD.  Of course, you'll have to process the
.\" output yourself in some meaningful fashion.
.\"
.\" Avoid warning from groff about undefined register 'F'.
.de IX
..
.nr rF 0
.if \n(.g .if rF .nr rF 1
.if (\n(rF:(\n(.g==0)) \{
.    if \nF \{
.        de IX
.        tm Index:\\$1\t\\n%\t"\\$2"
..
.        if !\nF==2 \{
.            nr % 0
.            nr F 2
.        \}
.    \}
.\}
.rr rF
.\"
.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
.\" Fear.  Run.  Save yourself.  No user-serviceable parts.
.    \" fudge factors for nroff and troff
.if n \{\
.    ds #H 0
.    ds #V .8m
.    ds #F .3m
.    ds #[ \f1
.    ds #] \fP
.\}
.if t \{\
.    ds #H ((1u-(\\\\n(.fu%2u))*.13m)
.    ds #V .6m
.    ds #F 0
.    ds #[ \&
.    ds #] \&
.\}
.    \" simple accents for nroff and troff
.if n \{\
.    ds ' \&
.    ds ` \&
.    ds ^ \&
.    ds , \&
.    ds ~ ~
.    ds /
.\}
.if t \{\
.    ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
.    ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
.    ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
.    ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
.    ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
.    ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
.\}
.    \" troff and (daisy-wheel) nroff accents
.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
.ds 8 \h'\*(#H'\(*b\h'-\*(#H'
.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
.ds ae a\h'-(\w'a'u*4/10)'e
.ds Ae A\h'-(\w'A'u*4/10)'E
.    \" corrections for vroff
.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
.    \" for low resolution devices (crt and lpr)
.if \n(.H>23 .if \n(.V>19 \
\{\
.    ds : e
.    ds 8 ss
.    ds o a
.    ds d- d\h'-1'\(ga
.    ds D- D\h'-1'\(hy
.    ds th \o'bp'
.    ds Th \o'LP'
.    ds ae ae
.    ds Ae AE
.\}
.rm #[ #] #H #V #F C
.\" ========================================================================
.\"
.IX Title "XML::LibXML::Parser 3"
.TH XML::LibXML::Parser 3 "2016-07-24" "perl v5.16.3" "User Contributed Perl Documentation"
.\" For nroff, turn off justification.  Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.if n .ad l
.nh
.SH "NAME"
XML::LibXML::Parser \- Parsing XML Data with XML::LibXML
.SH "SYNOPSIS"
.IX Header "SYNOPSIS"
.Vb 1
\&  use XML::LibXML \*(Aq1.70\*(Aq;
\&
\&  # 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 => (\e$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, \e%opts );
\&  $doc = $parser\->parse_html_fh( $io_fh, \e%opts );
\&  $doc = $parser\->parse_html_string( $htmlstring, \e%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 );
.Ve
.SH "PARSING"
.IX Header "PARSING"
An \s-1XML\s0 document is read into a data structure such as a \s-1DOM\s0 tree by a piece of
software, called a parser. XML::LibXML currently provides four different parser
interfaces:
.IP "\(bu" 4
A \s-1DOM\s0 Pull-Parser
.IP "\(bu" 4
A \s-1DOM\s0 Push-Parser
.IP "\(bu" 4
A \s-1SAX\s0 Parser
.IP "\(bu" 4
A \s-1DOM\s0 based \s-1SAX\s0 Parser.
.SS "Creating a Parser Instance"
.IX Subsection "Creating a Parser Instance"
XML::LibXML provides an \s-1OO\s0 interface to the libxml2 parser functions. Thus you
have to create a parser instance before you can parse any \s-1XML\s0 data.
.IP "new" 4
.IX Item "new"
.Vb 3
\&  $parser = XML::LibXML\->new();
\&  $parser = XML::LibXML\->new(option=>value, ...);
\&  $parser = XML::LibXML\->new({option=>value, ...});
.Ve
.Sp
Create a new \s-1XML\s0 and \s-1HTML\s0 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 \f(CW\*(C`load_ext_dtd\*(C'\fR, and \f(CW\*(C`expand_entities\*(C'\fR are set to 1. See \*(L"Parser Options\*(R" for a list of libxml2 parser's options.
.SS "\s-1DOM\s0 Parser"
.IX Subsection "DOM Parser"
One of the common parser interfaces of XML::LibXML is the \s-1DOM\s0 parser. This
parser reads \s-1XML\s0 data into a \s-1DOM\s0 like data structure, so each tag can get
accessed and transformed.
.PP
XML::LibXML's \s-1DOM\s0 parser is not only capable to parse \s-1XML\s0 data, but also
(strict) \s-1HTML\s0 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 XML::LibXML::Document object, which is a \s-1DOM\s0 object.
.PP
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
.IP "load_xml" 4
.IX Item "load_xml"
.Vb 10
\&  $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 => (\e$xml_string)
\&      # parser options ...
\&    );
\&  $dom = XML::LibXML\->load_xml({
\&      IO => $perl_file_handle
\&      # parser options ...
\&    );
\&  $dom = $parser\->load_xml(...);
.Ve
.Sp
This function is available since XML::LibXML 1.70. It provides easy to use
interface to the \s-1XML\s0 parser that parses given file (or \s-1URL\s0), string, or input
stream to a \s-1DOM\s0 tree. The arguments can be passed in a \s-1HASH\s0 reference or as
name => value pairs. The function can be called as a class method or an object
method. In both cases it internally creates a new parser instance passing the
specified parser options; if called as an object method, it clones the original
parser (preserving its settings) and additionally applies the specified options
to the new parser. See the constructor \f(CW\*(C`new\*(C'\fR and \*(L"Parser Options\*(R" for more information.
.IP "load_html" 4
.IX Item "load_html"
.Vb 2
\&  $dom = XML::LibXML\->load_html(...);
\&  $dom = $parser\->load_html(...);
.Ve
.Sp
This function is available since XML::LibXML 1.70. It has the same usage as \f(CW\*(C`load_xml\*(C'\fR, providing interface to the \s-1HTML\s0 parser. See \f(CW\*(C`load_xml\*(C'\fR for more information.
.PP
Parsing \s-1HTML\s0 may cause problems, especially if the ampersand ('&') is used.
This is a common problem if \s-1HTML\s0 code is parsed that contains links to
CGI-scripts. Such links cause the parser to throw errors. In such cases libxml2
still parses the entire document as there was no error, but the error causes
XML::LibXML to stop the parsing process. However, the document is not lost.
Such \s-1HTML\s0 documents should be parsed using the \fIrecover\fR flag. By default recovering is deactivated.
.PP
The functions described above are implemented to parse well formed documents.
In some cases a program gets well balanced \s-1XML\s0 instead of well formed documents
(e.g. an \s-1XML\s0 fragment from a database). With XML::LibXML it is not required to
wrap such fragments in the code, because XML::LibXML is capable even to parse
well balanced \s-1XML\s0 fragments.
.IP "parse_balanced_chunk" 4
.IX Item "parse_balanced_chunk"
.Vb 1
\&  $fragment = $parser\->parse_balanced_chunk( $wbxmlstring, $encoding );
.Ve
.Sp
This function parses a well balanced \s-1XML\s0 string into a XML::LibXML::DocumentFragment. The first arguments contains the input string, the optional second argument
can be used to specify character encoding of the input (\s-1UTF\-8\s0 is assumed by
default).
.IP "parse_xml_chunk" 4
.IX Item "parse_xml_chunk"
This is the old name of \fIparse_balanced_chunk()\fR. Because it may causes confusion
with the push parser interface, this function should not be used anymore.
.PP
By default XML::LibXML does not process XInclude tags within an \s-1XML\s0 Document
(see options section below). XML::LibXML allows one to post-process a document
to expand XInclude tags.
.IP "process_xincludes" 4
.IX Item "process_xincludes"
.Vb 1
\&  $parser\->process_xincludes( $doc );
.Ve
.Sp
After a document is parsed into a \s-1DOM\s0 structure, you may want to expand the
documents XInclude tags. This function processes the given document structure
and expands all XInclude tags (or throws an error) by using the flags and
callbacks of the given parser instance.
.Sp
Note that the resulting Tree contains some extra nodes (of type
\&\s-1XML_XINCLUDE_START\s0 and \s-1XML_XINCLUDE_END\s0) after successfully processing the
document. These nodes indicate where data was included into the original tree.
if the document is serialized, these extra nodes will not show up.
.Sp
Remember: A Document with processed XIncludes differs from the original
document after serialization, because the original XInclude tags will not get
restored!
.Sp
If the parser flag \*(L"expand_xincludes\*(R" is set to 1, you need not to post process
the parsed document.
.IP "processXIncludes" 4
.IX Item "processXIncludes"
.Vb 1
\&  $parser\->processXIncludes( $doc );
.Ve
.Sp
This is an alias to process_xincludes, but through a \s-1JAVA\s0 like function name.
.IP "parse_file" 4
.IX Item "parse_file"
.Vb 1
\&  $doc = $parser\->parse_file( $xmlfilename );
.Ve
.Sp
This function parses an \s-1XML\s0 document from a file or network; \f(CW$xmlfilename\fR can
be either a filename or an \s-1URL.\s0 Note that for parsing files, this function is
the fastest choice, about 6\-8 times faster then \fIparse_fh()\fR.
.IP "parse_fh" 4
.IX Item "parse_fh"
.Vb 1
\&  $doc = $parser\->parse_fh( $io_fh );
.Ve
.Sp
\&\fIparse_fh()\fR parses a \s-1IOREF\s0 or a subclass of IO::Handle.
.Sp
Because the data comes from an open handle, libxml2's parser does not know
about the base \s-1URI\s0 of the document. To set the base \s-1URI\s0 one should use
\&\fIparse_fh()\fR as follows:
.Sp
.Vb 1
\&  my $doc = $parser\->parse_fh( $io_fh, $baseuri );
.Ve
.IP "parse_string" 4
.IX Item "parse_string"
.Vb 1
\&  $doc = $parser\->parse_string( $xmlstring);
.Ve
.Sp
This function is similar to \fIparse_fh()\fR, but it parses an \s-1XML\s0 document that is
available as a single string in memory, or alternatively as a reference to a
scalar containing a string. Again, you can pass an optional base \s-1URI\s0 to the
function.
.Sp
.Vb 2
\&  my $doc = $parser\->parse_string( $xmlstring, $baseuri );
\&  my $doc = $parser\->parse_string(\e$xmlstring, $baseuri);
.Ve
.IP "parse_html_file" 4
.IX Item "parse_html_file"
.Vb 1
\&  $doc = $parser\->parse_html_file( $htmlfile, \e%opts );
.Ve
.Sp
Similar to \fIparse_file()\fR but parses \s-1HTML \s0(strict) documents; \f(CW$htmlfile\fR can be
filename or \s-1URL.\s0
.Sp
An optional second argument can be used to pass some options to the \s-1HTML\s0 parser
as a \s-1HASH\s0 reference. See options labeled with \s-1HTML\s0 in \*(L"Parser Options\*(R".
.IP "parse_html_fh" 4
.IX Item "parse_html_fh"
.Vb 1
\&  $doc = $parser\->parse_html_fh( $io_fh, \e%opts );
.Ve
.Sp
Similar to \fIparse_fh()\fR but parses \s-1HTML \s0(strict) streams.
.Sp
An optional second argument can be used to pass some options to the \s-1HTML\s0 parser
as a \s-1HASH\s0 reference. See options labeled with \s-1HTML\s0 in \*(L"Parser Options\*(R".
.Sp
Note: encoding option may not work correctly with this function in libxml2 <
2.6.27 if the \s-1HTML\s0 file declares charset using a \s-1META\s0 tag.
.IP "parse_html_string" 4
.IX Item "parse_html_string"
.Vb 1
\&  $doc = $parser\->parse_html_string( $htmlstring, \e%opts );
.Ve
.Sp
Similar to \fIparse_string()\fR but parses \s-1HTML \s0(strict) strings.
.Sp
An optional second argument can be used to pass some options to the \s-1HTML\s0 parser
as a \s-1HASH\s0 reference. See options labeled with \s-1HTML\s0 in \*(L"Parser Options\*(R".
.SS "Push Parser"
.IX Subsection "Push Parser"
XML::LibXML provides a push parser interface. Rather than pulling the data from
a given source the push parser waits for the data to be pushed into it.
.PP
This allows one to parse large documents without waiting for the parser to
finish. The interface is especially useful if a program needs to pre-process
the incoming pieces of \s-1XML \s0(e.g. to detect document boundaries).
.PP
While XML::LibXML parse_*() functions force the data to be a well-formed \s-1XML,\s0
the push parser will take any arbitrary string that contains some \s-1XML\s0 data. The
only requirement is that all the pushed strings are together a well formed
document. With the push parser interface a program can interrupt the parsing
process as required, where the parse_*() functions give not enough flexibility.
.PP
Different to the pull parser implemented in \fIparse_fh()\fR or \fIparse_file()\fR, the
push parser is not able to find out about the documents end itself. Thus the
calling program needs to indicate explicitly when the parsing is done.
.PP
In XML::LibXML this is done by a single function:
.IP "parse_chunk" 4
.IX Item "parse_chunk"
.Vb 1
\&  $parser\->parse_chunk($string, $terminate);
.Ve
.Sp
\&\fIparse_chunk()\fR tries to parse a given chunk of data, which isn't necessarily
well balanced data. The function takes two parameters: The chunk of data as a
string and optional a termination flag. If the termination flag is set to a
true value (e.g. 1), the parsing will be stopped and the resulting document
will be returned as the following example describes:
.Sp
.Vb 5
\&  my $parser = XML::LibXML\->new;
\&  for my $string ( "<", "foo", \*(Aq bar="hello world"\*(Aq, "/>") {
\&       $parser\->parse_chunk( $string );
\&  }
\&  my $doc = $parser\->parse_chunk("", 1); # terminate the parsing
.Ve
.PP
Internally XML::LibXML provides three functions that control the push parser
process:
.IP "init_push" 4
.IX Item "init_push"
.Vb 1
\&  $parser\->init_push();
.Ve
.Sp
Initializes the push parser.
.IP "push" 4
.IX Item "push"
.Vb 1
\&  $parser\->push(@data);
.Ve
.Sp
This function pushes the data stored inside the array to libxml2's parser. Each
entry in \f(CW@data\fR must be a normal scalar! This method can be called repeatedly.
.IP "finish_push" 4
.IX Item "finish_push"
.Vb 1
\&  $doc = $parser\->finish_push( $recover );
.Ve
.Sp
This function returns the result of the parsing process. If this function is
called without a parameter it will complain about non well-formed documents. If
\&\f(CW$restore\fR is 1, the push parser can be used to restore broken or non well formed
(\s-1XML\s0) documents as the following example shows:
.Sp
.Vb 7
\&  eval {
\&      $parser\->push( "<foo>", "bar" );
\&      $doc = $parser\->finish_push();    # will report broken XML
\&  };
\&  if ( $@ ) {
\&     # ...
\&  }
.Ve
.Sp
This can be annoying if the closing tag is missed by accident. The following
code will restore the document:
.Sp
.Vb 5
\&  eval {
\&      $parser\->push( "<foo>", "bar" );
\&      $doc = $parser\->finish_push(1);   # will return the data parsed
\&                                        # unless an error happened
\&  };
\&
\&  print $doc\->toString(); # returns "<foo>bar</foo>"
.Ve
.Sp
Of course \fIfinish_push()\fR will return nothing if there was no data pushed to the
parser before.
.SS "Pull Parser (Reader)"
.IX Subsection "Pull Parser (Reader)"
XML::LibXML also provides a pull-parser interface similar to the XmlReader
interface in .NET. This interface is almost streaming, and is usually faster
and simpler to use than \s-1SAX.\s0 See XML::LibXML::Reader.
.SS "Direct \s-1SAX\s0 Parser"
.IX Subsection "Direct SAX Parser"
XML::LibXML provides a direct \s-1SAX\s0 parser in the XML::LibXML::SAX module.
.SS "\s-1DOM\s0 based \s-1SAX\s0 Parser"
.IX Subsection "DOM based SAX Parser"
XML::LibXML also provides a \s-1DOM\s0 based \s-1SAX\s0 parser. The \s-1SAX\s0 parser is defined in
the module XML::LibXML::SAX::Parser. As it is not a stream based parser, it
parses documents into a \s-1DOM\s0 and traverses the \s-1DOM\s0 tree instead.
.PP
The \s-1API\s0 of this parser is exactly the same as any other Perl \s-1SAX2\s0 parser. See
XML::SAX::Intro for details.
.PP
Aside from the regular parsing methods, you can access the \s-1DOM\s0 tree traverser
directly, using the \fIgenerate()\fR method:
.PP
.Vb 3
\&  my $doc = build_yourself_a_document();
\&  my $saxparser = $XML::LibXML::SAX::Parser\->new( ... );
\&  $parser\->generate( $doc );
.Ve
.PP
This is useful for serializing \s-1DOM\s0 trees, for example that you might have done
prior processing on, or that you have as a result of \s-1XSLT\s0 processing.
.PP
\&\fI\s-1WARNING\s0\fR
.PP
This is \s-1NOT\s0 a streaming \s-1SAX\s0 parser. As I said above, this parser reads the
entire document into a \s-1DOM\s0 and serialises it. Some people couldn't read that in
the paragraph above so I've added this warning. If you want a streaming \s-1SAX\s0
parser look at the XML::LibXML::SAX man page
.SH "SERIALIZATION"
.IX Header "SERIALIZATION"
XML::LibXML provides some functions to serialize nodes and documents. The
serialization functions are described on the XML::LibXML::Node manpage or the XML::LibXML::Document manpage. XML::LibXML checks three global flags that alter the serialization
process:
.IP "\(bu" 4
skipXMLDeclaration
.IP "\(bu" 4
skipDTD
.IP "\(bu" 4
setTagCompression
.PP
of that three functions only setTagCompression is available for all
serialization functions.
.PP
Because XML::LibXML does these flags not itself, one has to define them locally
as the following example shows:
.PP
.Vb 3
\&  local $XML::LibXML::skipXMLDeclaration = 1;
\&  local $XML::LibXML::skipDTD = 1;
\&  local $XML::LibXML::setTagCompression = 1;
.Ve
.PP
If skipXMLDeclaration is defined and not '0', the \s-1XML\s0 declaration is omitted
during serialization.
.PP
If skipDTD is defined and not '0', an existing \s-1DTD\s0 would not be serialized with
the document.
.PP
If setTagCompression is defined and not '0' empty tags are displayed as open
and closing tags rather than the shortcut. For example the empty tag \fIfoo\fR will be rendered as \fI<foo></foo>\fR rather than \fI<foo/>\fR.
.SH "PARSER OPTIONS"
.IX Header "PARSER OPTIONS"
Handling of libxml2 parser options has been unified and improved in XML::LibXML
1.70. You can now set default options for a particular parser instance by
passing them to the constructor as \f(CW\*(C`XML::LibXML\->new({name=>value, ...})\*(C'\fR or \f(CW\*(C`XML::LibXML\->new(name=>value,...)\*(C'\fR. The options can be queried and changed using the following methods (pre\-1.70
interfaces such as \f(CW\*(C`$parser\->load_ext_dtd(0)\*(C'\fR also exist, see below):
.IP "option_exists" 4
.IX Item "option_exists"
.Vb 1
\&  $parser\->option_exists($name);
.Ve
.Sp
Returns 1 if the current XML::LibXML version supports the option \f(CW$name\fR, otherwise returns 0 (note that this does not necessarily mean that the option
is supported by the underlying libxml2 library).
.IP "get_option" 4
.IX Item "get_option"
.Vb 1
\&  $parser\->get_option($name);
.Ve
.Sp
Returns the current value of the parser option \f(CW$name\fR.
.IP "set_option" 4
.IX Item "set_option"
.Vb 1
\&  $parser\->set_option($name,$value);
.Ve
.Sp
Sets option \f(CW$name\fR to value \f(CW$value\fR.
.IP "set_options" 4
.IX Item "set_options"
.Vb 1
\&  $parser\->set_options({$name=>$value,...});
.Ve
.Sp
Sets multiple parsing options at once.
.PP
\&\s-1IMPORTANT NOTE:\s0 This documentation reflects the parser flags available in
libxml2 2.7.3. Some options have no effect if an older version of libxml2 is
used.
.PP
Each of the flags listed below is labeled
.IP "/parser/" 4
.IX Item "/parser/"
if it can be used with a \f(CW\*(C`XML::LibXML\*(C'\fR parser object (i.e. passed to \f(CW\*(C`XML::LibXML\->new\*(C'\fR, \f(CW\*(C`XML::LibXML\->set_option\*(C'\fR, etc.)
.IP "/html/" 4
.IX Item "/html/"
if it can be used passed to the \f(CW\*(C`parse_html_*\*(C'\fR methods
.IP "/reader/" 4
.IX Item "/reader/"
if it can be used with the \f(CW\*(C`XML::LibXML::Reader\*(C'\fR.
.PP
Unless specified otherwise, the default for boolean valued options is 0
(false).
.PP
The available options are:
.IP "\s-1URI\s0" 4
.IX Item "URI"
/parser, html, reader/
.Sp
In case of parsing strings or file handles, XML::LibXML doesn't know about the
base uri of the document. To make relative references such as XIncludes work,
one has to set a base \s-1URI,\s0 that is then used for the parsed document.
.IP "line_numbers" 4
.IX Item "line_numbers"
/parser, html, reader/
.Sp
If this option is activated, libxml2 will store the line number of each element
node in the parsed document. The line number can be obtained using the \f(CW\*(C`line_number()\*(C'\fR method of the \f(CW\*(C`XML::LibXML::Node\*(C'\fR class (for non-element nodes this may report the line number of the containing
element). The line numbers are also used for reporting positions of validation
errors.
.Sp
\&\s-1IMPORTANT:\s0 Due to limitations in the libxml2 library line numbers greater than
65535 will be returned as 65535. Unfortunately, this is a long and sad story,
please see <http://bugzilla.gnome.org/show_bug.cgi?id=325533> for more details.
.IP "encoding" 4
.IX Item "encoding"
/html/
.Sp
character encoding of the input
.IP "recover" 4
.IX Item "recover"
/parser, html, reader/
.Sp
recover from errors; possible values are 0, 1, and 2
.Sp
A true value turns on recovery mode which allows one to parse broken \s-1XML\s0 or
\&\s-1HTML\s0 data. The recovery mode allows the parser to return the successfully
parsed portion of the input document. This is useful for almost well-formed
documents, where for example a closing tag is missing somewhere. Still,
XML::LibXML will only parse until the first fatal (non-recoverable) error
occurs, reporting recoverable parsing errors as warnings. To suppress even
these warnings, use recover=>2.
.Sp
Note that validation is switched off automatically in recovery mode.
.IP "expand_entities" 4
.IX Item "expand_entities"
/parser, reader/
.Sp
substitute entities; possible values are 0 and 1; default is 1
.Sp
Note that although this flag disables entity substitution, it does not prevent
the parser from loading external entities; when substitution of an external
entity is disabled, the entity will be represented in the document tree by an
\&\s-1XML_ENTITY_REF_NODE\s0 node whose subtree will be the content obtained by parsing
the external resource; Although this nesting is visible from the \s-1DOM\s0 it is
transparent to XPath data model, so it is possible to match nodes in an
unexpanded entity by the same XPath expression as if the entity were expanded.
See also ext_ent_handler.
.IP "ext_ent_handler" 4
.IX Item "ext_ent_handler"
/parser/
.Sp
Provide a custom external entity handler to be used when expand_entities is set
to 1. Possible value is a subroutine reference.
.Sp
This feature does not work properly in libxml2 < 2.6.27!
.Sp
The subroutine provided is called whenever the parser needs to retrieve the
content of an external entity. It is called with two arguments: the system \s-1ID
\&\s0(\s-1URI\s0) and the public \s-1ID.\s0 The value returned by the subroutine is parsed as the
content of the entity.
.Sp
This method can be used to completely disable entity loading, e.g. to prevent
exploits of the type described at  (<http://searchsecuritychannel.techtarget.com/generic/0,295582,sid97_gci1304703,00.html>), where a service is tricked to expose its private data by letting it parse a
remote file (\s-1RSS\s0 feed) that contains an entity reference to a local file (e.g. \f(CW\*(C`/etc/fstab\*(C'\fR).
.Sp
A more granular solution to this problem, however, is provided by custom \s-1URL\s0
resolvers, as in
.Sp
.Vb 9
\&  my $c = XML::LibXML::InputCallback\->new();
\&  sub match {   # accept file:/ URIs except for XML catalogs in /etc/xml/
\&    my ($uri) = @_;
\&    return ($uri=~m{^file:/}
\&            and $uri !~ m{^file:///etc/xml/})
\&           ? 1 : 0;
\&  }
\&  $c\->register_callbacks([ \e&match, sub{}, sub{}, sub{} ]);
\&  $parser\->input_callbacks($c);
.Ve
.IP "load_ext_dtd" 4
.IX Item "load_ext_dtd"
/parser, reader/
.Sp
load the external \s-1DTD\s0 subset while parsing; possible values are 0 and 1. Unless
specified, XML::LibXML sets this option to 1.
.Sp
This flag is also required for \s-1DTD\s0 Validation, to provide complete attribute,
and to expand entities, regardless if the document has an internal subset. Thus
switching off external \s-1DTD\s0 loading, will disable entity expansion, validation,
and complete attributes on internal subsets as well.
.IP "complete_attributes" 4
.IX Item "complete_attributes"
/parser, reader/
.Sp
create default \s-1DTD\s0 attributes; possible values are 0 and 1
.IP "validation" 4
.IX Item "validation"
/parser, reader/
.Sp
validate with the \s-1DTD\s0; possible values are 0 and 1
.IP "suppress_errors" 4
.IX Item "suppress_errors"
/parser, html, reader/
.Sp
suppress error reports; possible values are 0 and 1
.IP "suppress_warnings" 4
.IX Item "suppress_warnings"
/parser, html, reader/
.Sp
suppress warning reports; possible values are 0 and 1
.IP "pedantic_parser" 4
.IX Item "pedantic_parser"
/parser, html, reader/
.Sp
pedantic error reporting; possible values are 0 and 1
.IP "no_blanks" 4
.IX Item "no_blanks"
/parser, html, reader/
.Sp
remove blank nodes; possible values are 0 and 1
.IP "no_defdtd" 4
.IX Item "no_defdtd"
/html/
.Sp
do not add a default \s-1DOCTYPE\s0; possible values are 0 and 1
.Sp
the default is (0) to add a \s-1DTD\s0 when the input html lacks one
.IP "expand_xinclude or xinclude" 4
.IX Item "expand_xinclude or xinclude"
/parser, reader/
.Sp
Implement XInclude substitution; possible values are 0 and 1
.Sp
Expands XInclude tags immediately while parsing the document. Note that the
parser will use the \s-1URI\s0 resolvers installed via \f(CW\*(C`XML::LibXML::InputCallback\*(C'\fR to parse the included document (if any).
.IP "no_xinclude_nodes" 4
.IX Item "no_xinclude_nodes"
/parser, reader/
.Sp
do not generate \s-1XINCLUDE START/END\s0 nodes; possible values are 0 and 1
.IP "no_network" 4
.IX Item "no_network"
/parser, html, reader/
.Sp
Forbid network access; possible values are 0 and 1
.Sp
If set to true, all attempts to fetch non-local resources (such as \s-1DTD\s0 or
external entities) will fail (unless custom callbacks are defined).
.Sp
It may be necessary to use the flag \f(CW\*(C`recover\*(C'\fR for processing documents requiring such resources while networking is off.
.IP "clean_namespaces" 4
.IX Item "clean_namespaces"
/parser, reader/
.Sp
remove redundant namespaces declarations during parsing; possible values are 0
and 1.
.IP "no_cdata" 4
.IX Item "no_cdata"
/parser, html, reader/
.Sp
merge \s-1CDATA\s0 as text nodes; possible values are 0 and 1
.IP "no_basefix" 4
.IX Item "no_basefix"
/parser, reader/
.Sp
not fixup \s-1XINCLUDE\s0 xml#base \s-1URIS\s0; possible values are 0 and 1
.IP "huge" 4
.IX Item "huge"
/parser, html, reader/
.Sp
relax any hardcoded limit from the parser; possible values are 0 and 1. Unless
specified, XML::LibXML sets this option to 0.
.Sp
Note: the default value for this option was changed to protect against denial
of service through entity expansion attacks. Before enabling the option ensure
you have taken alternative measures to protect your application against this
type of attack.
.IP "gdome" 4
.IX Item "gdome"
/parser/
.Sp
\&\s-1THIS OPTION IS EXPERIMENTAL\s0!
.Sp
Although quite powerful, XML::LibXML's \s-1DOM\s0 implementation is incomplete with
respect to the \s-1DOM\s0 level 2 or level 3 specifications. \s-1XML::GDOME\s0 is based on
libxml2 as well, and provides a rather complete \s-1DOM\s0 implementation by wrapping
libgdome. This flag allows you to make use of XML::LibXML's full parser options
and \s-1XML::GDOME\s0's \s-1DOM\s0 implementation at the same time.
.Sp
To make use of this function, one has to install libgdome and configure
XML::LibXML to use this library. For this you need to rebuild XML::LibXML!
.Sp
Note: this feature was not seriously tested in recent XML::LibXML releases.
.PP
For compatibility with XML::LibXML versions prior to 1.70, the following
methods are also supported for querying and setting the corresponding parser
options (if called without arguments, the methods return the current value of
the corresponding parser options; with an argument sets the option to a given
value):
.PP
.Vb 10
\&  $parser\->validation();
\&  $parser\->recover();
\&  $parser\->pedantic_parser();
\&  $parser\->line_numbers();
\&  $parser\->load_ext_dtd();
\&  $parser\->complete_attributes();
\&  $parser\->expand_xinclude();
\&  $parser\->gdome_dom();
\&  $parser\->clean_namespaces();
\&  $parser\->no_network();
.Ve
.PP
The following obsolete methods trigger parser options in some special way:
.IP "recover_silently" 4
.IX Item "recover_silently"
.Vb 1
\&  $parser\->recover_silently(1);
.Ve
.Sp
If called without an argument, returns true if the current value of the \f(CW\*(C`recover\*(C'\fR parser option is 2 and returns false otherwise. With a true argument sets the \f(CW\*(C`recover\*(C'\fR parser option to 2; with a false argument sets the \f(CW\*(C`recover\*(C'\fR parser option to 0.
.IP "expand_entities" 4
.IX Item "expand_entities"
.Vb 1
\&  $parser\->expand_entities(0);
.Ve
.Sp
Get/set the \f(CW\*(C`expand_entities\*(C'\fR option. If called with a true argument, also turns the \f(CW\*(C`load_ext_dtd\*(C'\fR option to 1.
.IP "keep_blanks" 4
.IX Item "keep_blanks"
.Vb 1
\&  $parser\->keep_blanks(0);
.Ve
.Sp
This is actually the opposite of the \f(CW\*(C`no_blanks\*(C'\fR parser option. If used without an argument retrieves negated value of \f(CW\*(C`no_blanks\*(C'\fR. If used with an argument sets \f(CW\*(C`no_blanks\*(C'\fR to the opposite value.
.IP "base_uri" 4
.IX Item "base_uri"
.Vb 1
\&  $parser\->base_uri( $your_base_uri );
.Ve
.Sp
Get/set the \f(CW\*(C`URI\*(C'\fR option.
.SH "XML CATALOGS"
.IX Header "XML CATALOGS"
\&\f(CW\*(C`libxml2\*(C'\fR supports \s-1XML\s0 catalogs. Catalogs are used to map remote resources to their local
copies. Using catalogs can speed up parsing processes if many external
resources from remote addresses are loaded into the parsed documents (such as
DTDs or XIncludes).
.PP
Note that libxml2 has a global pool of loaded catalogs, so if you apply the
method \f(CW\*(C`load_catalog\*(C'\fR to one parser instance, all parser instances will start using the catalog (in
addition to other previously loaded catalogs).
.PP
Note also that catalogs are not used when a custom external entity handler is
specified. At the current state it is not possible to make use of both types of
resolving systems at the same time.
.IP "load_catalog" 4
.IX Item "load_catalog"
.Vb 1
\&  $parser\->load_catalog( $catalog_file );
.Ve
.Sp
Loads the \s-1XML\s0 catalog file \f(CW$catalog_file\fR.
.Sp
.Vb 2
\&  # Global external entity loader (similar to ext_ent_handler option
\&  # but this works really globally, also in XML::LibXSLT include etc..)
\&
\&  XML::LibXML::externalEntityLoader(\e&my_loader);
.Ve
.SH "ERROR REPORTING"
.IX Header "ERROR REPORTING"
XML::LibXML throws exceptions during parsing, validation or XPath processing
(and some other occasions). These errors can be caught by using \fIeval\fR blocks. The error is stored in \fI$@\fR. There are two implementations: the old one throws $@ which is just a message
string, in the new one $@ is an object from the class XML::LibXML::Error; this
class overrides the operator "" so that when printed, the object flattens to
the usual error message.
.PP
XML::LibXML throws errors as they occur. This is a very common misunderstanding
in the use of XML::LibXML. If the eval is omitted, XML::LibXML will always halt
your script by \*(L"croaking\*(R" (see Carp man page for details).
.PP
Also note that an increasing number of functions throw errors if bad data is
passed as arguments. If you cannot assure valid data passed to XML::LibXML you
should eval these functions.
.PP
Note: since version 1.59, \fIget_last_error()\fR is no longer available in
XML::LibXML for thread-safety reasons.
.SH "AUTHORS"
.IX Header "AUTHORS"
Matt Sergeant,
Christian Glahn,
Petr Pajas
.SH "VERSION"
.IX Header "VERSION"
2.0128
.SH "COPYRIGHT"
.IX Header "COPYRIGHT"
2001\-2007, AxKit.com Ltd.
.PP
2002\-2006, Christian Glahn.
.PP
2006\-2009, Petr Pajas.
.SH "LICENSE"
.IX Header "LICENSE"
This program is free software; you can redistribute it and/or modify it under
the same terms as Perl itself.

Youez - 2016 - github.com/yon3zu
LinuXploit