NAME

XML::GDOME::Document - Interface Document implementation.

SYNOPSIS

$docType  = $doc->getDoctype();
$elem     = $doc->getDocumentElement();
$DOMImpl  = $doc->getImplementation();
$attr     = $doc->createAttribute($name);
$attr     = $doc->createAttributeNS($namespaceURI,$qualifiedName);
$cdata    = $doc->createCDATASection($data);
$comment  = $doc->createComment($data);
$docFrag  = $doc->createDocumentFragment();
$elem     = $doc->createElement($tagName);
$elem     = $doc->createElementNS($namespaceURI,$qualifiedName);
$entRef   = $doc->createEntityReference($name);
$pi       = $doc->createProcessingInstruction($target,$data);
$text     = $doc->createTextNode($data);
$elem     = $doc->getElementById($elementId);
$nodeList = $doc->getElementsByTagName($tagname);
$nodeList = $doc->getElementsByTagNameNS($namespaceURI,$localName);
$node     = $doc->importNode($importedNode,$deep);
$str      = $doc->toString($mode);
$str      = $doc->toStringEnc($encoding,$mode);

CLASS INHERITANCE

XML::GDOME::Node > XML::GDOME::Document

METHODS

$docType = $doc->getDoctype();

Returns: The Document Type Declaration associated with this document. The DOM Level 2 does not support editing the Document Type Declaration. docType cannot be altered in any way, including through the use of methods inherited from the Node interface, such as insertNode or removeNode.

$elem = $doc->getDocumentElement();

Returns: the root Element of the Document.

$DOMImpl = $doc->getImplementation();

Returns: the DOMImplementation object that handles this document.

$attr = $doc->createAttribute($name);

Creates an Attr of the given name. Note that the Attr instance can then be set on an Element using the setAttributeNode method. To create an attribute with a qualified name and namespace URI, use the gdome_doc_createAttributeNS() method.

name: The name of the attribute

Returns: a new Attr object with the nodeName attribute set to name, and localName, prefix, and namespaceURI set to undef. The value of the attribute is the empty string.

$attr = $doc->createAttributeNS($namespaceURI,$qualifiedName);

Creates an attribute of the given qualified name and namespace URI.

namespaceURI: The namespace URI of the attribute to create

qualifiedName: The qualified name of the attribute to create

Returns: a new Attr object with the following attributes: %Node.nodeName = qualifiedName, %Node.namespaceURI = namespaceURI, %Node.prefix = prefix, extracted from qualifiedName, %Node.localName = localName, extracted from qualifiedName, %Attr.name = qualifiedName, %Node.nodeValue = the empty string.

GDOME_NAMESPACE_ERR: Raised if the qualifiedName is malformed, if the qualifiedName has a prefix and the namespaceURI is %NUKK, if the qualifiedName has a prefix that is "xml" and the namespaceURI is different from "http://www.w3.org/XML/1998/namespace", or if the qualifiedName is "xmlns" and the namespaceURI is different from "http://www.w3.org/2000/xmlns/".

$cdata = $doc->createCDATASection($data);

Creates a CDATASection node whose value is the specified string.

data: The data for the CDATASection contents

Returns: the new CDATASection object.

$comment = $doc->createComment($data);

Creates a Comment node whose value is the specified string.

data: The data for the comment contents

Returns: the new Comment object.

$docFrag = $doc->createDocumentFragment();

Creates an empty DocumentFragment object.

Returns: the new DocumentFragment object.

$elem = $doc->createElement($tagName);

Creates an element of the type specified. Note that the instance returned implements the Element interface, so attributes can be specified directly on the returned object. To create an element with a qualified name and namespace URI, use the gdome_doc_createElementNS() function.

tagName: The name of the element type to instantiate.

Returns: a new Element object with the nodeName attribute set to tagName, and localName, prefix, and namespaceURI set to undef.

$elem = $doc->createElementNS($namespaceURI,$qualifiedName);

Creates an element of the given qualified name and namespace URI.

namespaceURI: The namespace URI of the element to create

qualifiedName: The qualified name of the element to create

Returns: a new Element object with the following attributes: %Node.nodeName = qualifiedName, %Node.namespaceURI = namespaceURI, %Node.prefix = prefix, extracted from qualifiedName, %Node.localName = localName, extracted from qualifiedName, %Element.tagName = qualifiedName.

GDOME_NAMESPACE_ERR: Raised if the qualifiedName is malformed, if the qualifiedName has a prefix and the namespaceURI is undef, or if the qualifiedName has a prefix that is "xml" and the namespaceURI is different from "http://www.w3.org/XML/1998/namespace".

$entRef = $doc->createEntityReference($name);

Creates an EntityReference object. In addition, if the referenced entity is known, the child list of the EntityReference node is made the same as that of the corresponding Entity node.

name: The name of the entity to reference

Returns: the new EntityReference object.

$pi = $doc->createProcessingInstruction($target,$data);

Creates a ProcessingInstruction node given the specified name and data strings.

target: The target part of the processing instruction

data: The data for the node

Returns: The new ProcessingInstruction object.

$text = $doc->createTextNode($data);

Creates a Text node given the specified string.

data: The data for the node

Returns: The new TextNode object.

$elem = $doc->getElementById($elementId);

elementId: The unique id value for an element

Returns: the Element whose %ID is given by elementId. If no such element exists, returns undef. Behavior is not defined if more than one element has this %ID.

$nodeList = $doc->getElementsByTagName($tagname);

tagName: The name of the tag to match on. The special value * matches all tags.

Returns: a NodeList of all the elements with a given tag name in the order in which they are encountered in a preorder traversal of the Document tree.

$nodeList = $doc->getElementsByTagNameNS($namespaceURI,$localName);

namespaceURI: The namespace URI of the elements to match on. The special value * matches all namespaces.

localName: The local name of the elements to match on. The special value * matches all local names.

Returns: a NodeList of all the descendant elements with a given local name and namespace URI in the order in which they are encountered in a preorder traversal of this Document tree.

$node = $doc->importNode($importedNode,$deep);

Imports a node from another document to this document. The returned node has no parent; (parentNode is undef). The source node is not altered or removed from the original document; this method creates a new copy of the source node. DOCUMENT, DOCUMENT_TYPE, NOTATION and ENTITY nodes are not supported.

importedNode: The node to import.

deep: If 1, recursively import the subtree under the specified node; if 0, import only the node itself. This has no effect on Attr, EntityReference, and Notation nodes.

Returns: the imported node that belongs to this Document.

GDOME_NOT_SUPPORTED_ERR: Raised if the type of node being imported is not supported.

$str = $doc->toString($mode);

Save the DOM tree of the Document to a string

mode: the indentation mode wanted, either GDOME_SAVE_STANDARD or GDOME_SAVE_LIBXML_INDENT

encoding: character encoding to use when generating XML text

Returns: string representation of DOM tree using the specified character encoding standard