1XML::DOM::Parser(3)   User Contributed Perl Documentation  XML::DOM::Parser(3)
2
3
4

NAME

6       XML::DOM::Parser - An XML::Parser that builds XML::DOM document
7       structures
8

SYNOPSIS

10        use XML::DOM;
11
12        my $parser = new XML::DOM::Parser;
13        my $doc = $parser->parsefile ("file.xml");
14        $doc->dispose; # Avoid memory leaks - cleanup circular references
15

DESCRIPTION

17       XML::DOM::Parser extends XML::Parser
18
19       The XML::Parser module was written by Clark Cooper and is built on top
20       of XML::Parser::Expat, which is a lower level interface to James
21       Clark's expat library.
22
23       XML::DOM::Parser parses XML strings or files and builds a data
24       structure that conforms to the API of the Document Object Model as
25       described at <http://www.w3.org/TR/REC-DOM-Level-1>.  See the
26       XML::Parser manpage for other additional properties of the
27       XML::DOM::Parser class.  Note that the 'Style' property should not be
28       used (it is set internally.)
29
30       The XML::Parser NoExpand option is more or less supported, in that it
31       will generate EntityReference objects whenever an entity reference is
32       encountered in character data. I'm not sure how useful this is. Any
33       comments are welcome.
34
35       As described in the synopsis, when you create an XML::DOM::Parser
36       object, the parse and parsefile methods create an XML::DOM::Document
37       object from the specified input. This Document object can then be
38       examined, modified and written back out to a file or converted to a
39       string.
40
41       When using XML::DOM with XML::Parser version 2.19 and up, setting the
42       XML::DOM::Parser option KeepCDATA to 1 will store CDATASections in
43       CDATASection nodes, instead of converting them to Text nodes.
44       Subsequent CDATASection nodes will be merged into one. Let me know if
45       this is a problem.
46

Using LWP to parse URLs

48       The parsefile() method now also supports URLs, e.g.
49       http://www.erols.com/enno/xsa.xml.  It uses LWP to download the file
50       and then calls parse() on the resulting string.  By default it will use
51       a LWP::UserAgent that is created as follows:
52
53        use LWP::UserAgent;
54        $LWP_USER_AGENT = LWP::UserAgent->new;
55        $LWP_USER_AGENT->env_proxy;
56
57       Note that env_proxy reads proxy settings from environment variables,
58       which is what I need to do to get thru our firewall. If you want to use
59       a different LWP::UserAgent, you can either set it globally with:
60
61        XML::DOM::Parser::set_LWP_UserAgent ($my_agent);
62
63       or, you can specify it for a specific XML::DOM::Parser by passing it to
64       the constructor:
65
66        my $parser = new XML::DOM::Parser (LWP_UserAgent => $my_agent);
67
68       Currently, LWP is used when the filename (passed to parsefile) starts
69       with one of the following URL schemes: http, https, ftp, wais, gopher,
70       or file (followed by a colon.)  If I missed one, please let me know.
71
72       The LWP modules are part of libwww-perl which is available at CPAN.
73
74
75
76perl v5.32.0                      2020-07-28               XML::DOM::Parser(3)
Impressum