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
22 getDocumentElement
23 This is a convenience method that allows direct access to the child
24 node that is the root Element of the document.
25
26 getDoctype
27 The Document Type Declaration (see DocumentType) associated with
28 this document. For HTML documents as well as XML documents without
29 a document type declaration this returns undef. The DOM Level 1
30 does not support editing the Document Type Declaration.
31
32 Not In DOM Spec: This implementation allows editing the doctype.
33 See XML::DOM::ignoreReadOnly for details.
34
35 getImplementation
36 The DOMImplementation object that handles this document. A DOM
37 application may use objects from multiple implementations.
38
39 createElement (tagName)
40 Creates an element of the type specified. Note that the instance
41 returned implements the Element interface, so attributes can be
42 specified directly on the returned object.
43
44 DOMExceptions:
45
46 * INVALID_CHARACTER_ERR
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 Raised if the name does not conform to the XML spec.
79
80 createProcessingInstruction (target, data)
81 Creates a ProcessingInstruction node given the specified name and
82 data strings.
83
84 Parameters:
85 target The target part of the processing instruction.
86 data The data for the node.
87
88 DOMExceptions:
89
90 * INVALID_CHARACTER_ERR
91 Raised if the target does not conform to the XML spec.
92
93 createDocumentFragment
94 Creates an empty DocumentFragment object.
95
96 createEntityReference (name)
97 Creates an EntityReference object.
98
99 Additional methods not in the DOM Spec
100
101 getXMLDecl and setXMLDecl (xmlDecl)
102 Returns the XMLDecl for this Document or undef if none was speci‐
103 fied. Note that XMLDecl is not part of the list of child nodes.
104
105 setDoctype (doctype)
106 Sets or replaces the DocumentType. NOTE: Don't use appendChild or
107 insertBefore to set the DocumentType. Even though doctype will be
108 part of the list of child nodes, it is handled specially.
109
110 getDefaultAttrValue (elem, attr)
111 Returns the default attribute value as a string or undef, if none
112 is available.
113
114 Parameters:
115 elem The element tagName.
116 attr The attribute name.
117
118 getEntity (name)
119 Returns the Entity with the specified name.
120
121 createXMLDecl (version, encoding, standalone)
122 Creates an XMLDecl object. All parameters may be undefined.
123
124 createDocumentType (name, sysId, pubId)
125 Creates a DocumentType object. SysId and pubId may be undefined.
126
127 createNotation (name, base, sysId, pubId)
128 Creates a new Notation object. Consider using XML::DOM::Document‐
129 Type::addNotation!
130
131 createEntity (parameter, notationName, value, sysId, pubId, ndata)
132 Creates an Entity object. Consider using XML::DOM::Document‐
133 Type::addEntity!
134
135 createElementDecl (name, model)
136 Creates an ElementDecl object.
137
138 DOMExceptions:
139
140 * INVALID_CHARACTER_ERR
141 Raised if the element name (tagName) does not conform to the
142 XML spec.
143
144 createAttlistDecl (name)
145 Creates an AttlistDecl object.
146
147 DOMExceptions:
148
149 * INVALID_CHARACTER_ERR
150 Raised if the element name (tagName) does not conform to the
151 XML spec.
152
153 expandEntity (entity [, parameter])
154 Expands the specified entity or parameter entity (if parameter=1)
155 and returns its value as a string, or undef if the entity does not
156 exist. (The entity name should not contain the '%', '&' or ';'
157 delimiters.)
158
159 check ( [$checker] )
160 Uses the specified XML::Checker to validate the document. If no
161 XML::Checker is supplied, a new XML::Checker is created. See
162 XML::Checker for details.
163
164 check_sax ( [$checker] )
165 Similar to check() except it uses the SAX interface to XML::Checker
166 instead of the expat interface. This method may disappear or
167 replace check() at some time.
168
169 createChecker ()
170 Creates an XML::Checker based on the document's DTD. The $checker
171 can be reused to check any elements within the document. Create a
172 new XML::Checker whenever the DOCTYPE section of the document is
173 altered!
174
175
176
177perl v5.8.8 2002-02-08 XML::DOM::Document(3)