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 struc‐
7       tures
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 struc‐
24       ture that conforms to the API of the Document Object Model as described
25       at <http://www.w3.org/TR/REC-DOM-Level-1>.  See the XML::Parser manpage
26       for other additional properties of the XML::DOM::Parser class.  Note
27       that the 'Style' property should not be used (it is set internally.)
28
29       The XML::Parser NoExpand option is more or less supported, in that it
30       will generate EntityReference objects whenever an entity reference is
31       encountered in character data. I'm not sure how useful this is. Any
32       comments are welcome.
33
34       As described in the synopsis, when you create an XML::DOM::Parser
35       object, the parse and parsefile methods create an XML::DOM::Document
36       object from the specified input. This Document object can then be exam‐
37       ined, modified and written back out to a file or converted to a string.
38
39       When using XML::DOM with XML::Parser version 2.19 and up, setting the
40       XML::DOM::Parser option KeepCDATA to 1 will store CDATASections in
41       CDATASection nodes, instead of converting them to Text nodes.  Subse‐
42       quent CDATASection nodes will be merged into one. Let me know if this
43       is a problem.
44

Using LWP to parse URLs

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