1XML::DOM::Document(3) User Contributed Perl DocumentationXML::DOM::Document(3)
2
3
4
6 XML::DOM::Document - An XML document node in XML::DOM
7
9 XML::DOM::Document extends XML::DOM::Node.
10
11 It is the main root of the XML document structure as returned by
12 XML::DOM::Parser::parse and XML::DOM::Parser::parsefile.
13
14 Since elements, text nodes, comments, processing instructions, etc.
15 cannot exist outside the context of a Document, the Document interface
16 also contains the factory methods needed to create these objects. The
17 Node objects created have a getOwnerDocument method which associates
18 them with the Document within whose context they were created.
19
20 METHODS
21 getDocumentElement
22 This is a convenience method that allows direct access to the child
23 node that is the root Element of the document.
24
25 getDoctype
26 The Document Type Declaration (see DocumentType) associated with
27 this document. For HTML documents as well as XML documents without
28 a document type declaration this returns undef. The DOM Level 1
29 does not support editing the Document Type Declaration.
30
31 Not In DOM Spec: This implementation allows editing the doctype.
32 See XML::DOM::ignoreReadOnly for details.
33
34 getImplementation
35 The DOMImplementation object that handles this document. A DOM
36 application may use objects from multiple implementations.
37
38 createElement (tagName)
39 Creates an element of the type specified. Note that the instance
40 returned implements the Element interface, so attributes can be
41 specified directly on the returned object.
42
43 DOMExceptions:
44
45 · INVALID_CHARACTER_ERR
46
47 Raised if the tagName does not conform to the XML spec.
48
49 createTextNode (data)
50 Creates a Text node given the specified string.
51
52 createComment (data)
53 Creates a Comment node given the specified string.
54
55 createCDATASection (data)
56 Creates a CDATASection node given the specified string.
57
58 createAttribute (name [, value [, specified ]])
59 Creates an Attr of the given name. Note that the Attr instance can
60 then be set on an Element using the setAttribute method.
61
62 Not In DOM Spec: The DOM Spec does not allow passing the value or
63 the specified property in this method. In this implementation they
64 are optional.
65
66 Parameters:
67 value The attribute's value. See Attr::setValue for details.
68 If the value is not supplied, the specified property
69 is set to 0.
70 specified Whether the attribute value was specified or whether the
71 default
72 value was used. If not supplied, it's assumed to be
73 1.
74
75 DOMExceptions:
76
77 · INVALID_CHARACTER_ERR
78
79 Raised if the name does not conform to the XML spec.
80
81 createProcessingInstruction (target, data)
82 Creates a ProcessingInstruction node given the specified name and
83 data strings.
84
85 Parameters:
86 target The target part of the processing instruction.
87 data The data for the node.
88
89 DOMExceptions:
90
91 · INVALID_CHARACTER_ERR
92
93 Raised if the target does not conform to the XML spec.
94
95 createDocumentFragment
96 Creates an empty DocumentFragment object.
97
98 createEntityReference (name)
99 Creates an EntityReference object.
100
101 Additional methods not in the DOM Spec
102 getXMLDecl and setXMLDecl (xmlDecl)
103 Returns the XMLDecl for this Document or undef if none was
104 specified. Note that XMLDecl is not part of the list of child
105 nodes.
106
107 setDoctype (doctype)
108 Sets or replaces the DocumentType. NOTE: Don't use appendChild or
109 insertBefore to set the DocumentType. Even though doctype will be
110 part of the list of child nodes, it is handled specially.
111
112 getDefaultAttrValue (elem, attr)
113 Returns the default attribute value as a string or undef, if none
114 is available.
115
116 Parameters:
117 elem The element tagName.
118 attr The attribute name.
119
120 getEntity (name)
121 Returns the Entity with the specified name.
122
123 createXMLDecl (version, encoding, standalone)
124 Creates an XMLDecl object. All parameters may be undefined.
125
126 createDocumentType (name, sysId, pubId)
127 Creates a DocumentType object. SysId and pubId may be undefined.
128
129 createNotation (name, base, sysId, pubId)
130 Creates a new Notation object. Consider using
131 XML::DOM::DocumentType::addNotation!
132
133 createEntity (parameter, notationName, value, sysId, pubId, ndata)
134 Creates an Entity object. Consider using
135 XML::DOM::DocumentType::addEntity!
136
137 createElementDecl (name, model)
138 Creates an ElementDecl object.
139
140 DOMExceptions:
141
142 · INVALID_CHARACTER_ERR
143
144 Raised if the element name (tagName) does not conform to the
145 XML spec.
146
147 createAttlistDecl (name)
148 Creates an AttlistDecl object.
149
150 DOMExceptions:
151
152 · INVALID_CHARACTER_ERR
153
154 Raised if the element name (tagName) does not conform to the
155 XML spec.
156
157 expandEntity (entity [, parameter])
158 Expands the specified entity or parameter entity (if parameter=1)
159 and returns its value as a string, or undef if the entity does not
160 exist. (The entity name should not contain the '%', '&' or ';'
161 delimiters.)
162
163 check ( [$checker] )
164 Uses the specified XML::Checker to validate the document. If no
165 XML::Checker is supplied, a new XML::Checker is created. See
166 XML::Checker for details.
167
168 check_sax ( [$checker] )
169 Similar to check() except it uses the SAX interface to XML::Checker
170 instead of the expat interface. This method may disappear or
171 replace check() at some time.
172
173 createChecker ()
174 Creates an XML::Checker based on the document's DTD. The $checker
175 can be reused to check any elements within the document. Create a
176 new XML::Checker whenever the DOCTYPE section of the document is
177 altered!
178
179
180
181perl v5.28.0 2001-08-26 XML::DOM::Document(3)