T.J. Mather > XML-GDOME-0.86 > XML::GDOME::Element

Download:
XML-GDOME-0.86.tar.gz

Annotate this POD

CPAN RT

New  6
Open  0
View/Report Bugs
Source  

NAME ^

  XML::GDOME::Element - Interface Element implementation.

SYNOPSIS ^

  $str      = $el->getTagName();
  $str      = $el->getAttribute($name);
  $str      = $el->getAttributeNS($namespaceURI,$localName);
  $attr     = $el->getAttributeNode($name);
  $attr     = $el->getAttributeNodeNS($namespaceURI,$localName);
  $nodeList = $el->getElementsByTagName($name);
  $nodeList = $el->getElementsByTagNameNS($namespaceURI,$localName);
  $bool     = $el->hasAttribute($name);
  $bool     = $el->hasAttributeNS($namespaceURI,$localName);
              $el->removeAttribute($name);
              $el->removeAttributeNS($namespaceURI,$localName);
  $attr     = $el->removeAttributeNode($oldAttr);
              $el->setAttribute($name,$value);
              $el->setAttributeNS($namespaceURI,$qualifiedName,$value);
  $attr     = $el->setAttributeNode($newAttr);
  $attr     = $el->setAttributeNodeNS($newAttr);
              $elem->appendText($PCDATA);

CLASS INHERITANCE ^

XML::GDOME::Node > XML::GDOME::Element

METHODS ^

$str = $el->getTagName();

Returns: the qualified name of the element.

$str = $el->getAttribute($name);

Retrieves an attribute value by name.

name: The name of attribute of which the value is wanted

Returns: the Attr value as a string, or the empty string if that attribute does not have a specified or default value.

$str = $el->getAttributeNS($namespaceURI,$localName);

Retrieves an attribute value by local name and namespace URI.

namespaceURI: The namespaceURI of attribute to retrieve

localName: The localName of the attribute to retrieve

Returns: the Attr value as a string, or the empty string if that attribute does not have a specified or default value.

$attr = $el->getAttributeNode($name);

Retrieves an attribute node by name. To retrieve an attribute node by qualified name and namespace URI, use the gdome_el_getAttributeNodeNS() method.

name: The name of the attribute to retreive

Returns: the Attr node with the specified name or undef if there is no such attribute.

$attr = $el->getAttributeNodeNS($namespaceURI,$localName);

Retrieves an Attr node by local name and namespace URI.

namespaceURI: The namespace URI of the attribute to retrieve.

localName: The local name of the attribute to retrieve.

Returns: the Attr node with the specified attribute local name and namespace URI or undef if there is no such attribute.

$nodeList = $el->getElementsByTagName($name);

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

Returns: a NodeList of all descendant elements with a given tag name, in the order in which they are encountered in a preorder traversal of this Element tree. In array context, returns array.

$nodeList = $el->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 Element tree. In array context, returns array.

$bool = $el->hasAttribute($name);

name: The name of the attribute to look for.

Returns: 1 when an attribute with a given name is specified on this element or has a default value, 0 otherwise.

$bool = $el->hasAttributeNS($namespaceURI,$localName);

namespaceURI: The namespaceURI of the attribute to look for.

localName: The localName of the attribute to look for.

Returns: 1 when an attribute with a given local name and namespace URI is specified on this element or has a default value, 0 otherwise.

$el->removeAttribute($name);

Removes an attribute by name. If the removed attribute is known to have a default value, an attribute immediately appears containing the default value as well as the corresponding namespace URI, local name, and prefix when applicable. To remove an attribute by local name and namespace URI, use the gdome_el_removeAttributeNS() function.

name: The name of the attribute to remove

GDOME_NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.

$el->removeAttributeNS($namespaceURI,$localName);

Removes an attribute by local name and namespace URI. If the removed attribute has a default value it is immediately replaced. The replacing attribute has the same namespace URI and local name, as well as the original prefix.

namespaceURI: The namespaceURI of attribute to remove

localName: The localName of the attribute to remove

GDOME_NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.

$attr = $el->removeAttributeNode($oldAttr);

Removes the specified attribute node. If the removed Attr has a default value it is immediately replaced. The replacing attribute has the same namespace URI and local name, as well as the original prefix, when applicable.

oldAttr: The Attr node to remove from the attribute list

Returns: the Attr node that was removed.

GDOME_NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.

GDOME_NOT_FOUND_ERR: Raised if oldAttr is not an attribute of the element.

$el->setAttribute($name,$value);

Adds a new attribute. If an attribute with that name is already present in the element, its value is changed to be that of the value parameter.

name: The name of the attribute to create or altervalue: Value to set in string form

GDOME_NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.

$el->setAttributeNS($namespaceURI,$qualifiedName,$value);

Adds a new attribute. If an attribute with the same namespaceURI and localName is already present in the element, its value is changed to be that of the value parameter.

namespaceURI: The namespace URI of attribute to create or alter

qualifiedName: The qualifiedName of the attribute to create or altervalue: Value to set in string form

GDOME_NAMESPACE_ERR: Raised if the qualifiedName is malformed, if the qualifiedName has a prefix and the namespaceURI is undef, 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/".

GDOME_NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.

$attr = $el->setAttributeNode($newAttr);

Adds a new attribute node. If an attribute with that name is already present in the element, it is replaced by the new one. To add a new attribute node with a qualified name and namespace URI, use the gdome_el_setAttributeNodeNS() method.

newAttr: The Attr node to add to the attribute list

Returns: if the newAttr attribute replaces an existing attribute, the replaced Attr node is returned, otherwise undef is returned.

GDOME_INUSE_ATTRIBUTE_ERR: Raised if newAttr is already an attribute of another Element object. The DOM user must explicitly clone Attr nodes to re-use them in other elements.

GDOME_NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.

GDOME_WRONG_DOCUMENT_ERR: Raised if newAttr was created from a different document than the one that created the element.

$attr = $el->setAttributeNodeNS($newAttr);

Adds a new attribute. If an attribute with that local name and that namespace URI is already present in the element, it is replaced by the new one.

newAttr: The Attr node to add to the attribute list

Returns: if the newAttr attribute replaces an existing attribute with the same local name and namespace URI, the replaced Attr node is returned, otherwise undef is returned.

GDOME_INUSE_ATTRIBUTE_ERR: Raised if newAttr is already an attribute of another Element object. The DOM user must explicitly clone Attr nodes to re-use them in other elements.

GDOME_NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.

GDOME_WRONG_DOCUMENT_ERR: Raised if newAttr was created from a different document than the one that created the element.

$elem->appendText($PCDATA);

This wrapper function lets you add a string directly to an element node.

syntax highlighting: