XML::DOM2::DOM::Element - A library of DOM (Document Object Model) methods for XML Elements.
Provides all the DOM method for XML Elements
Returns the elements first child in it's children list
Returns the elements last child in it's children list
Return the array index of this element in the parent or the passed list (if there is one).
Return the element at the specified index (the index can be negative).
Return the next element to this element in the parents child list.
Return the previous element to this element in the parents child list.
Returns all the elements children.
Returns all the elements children with that tag name (including namespace prefix).
Returns 1 if this element has children.
Returns the object of the parent element.
$element->setParent($parent);
Sets the parent node, used internaly.
Return a list of the parents of the current element, starting from the immediate parent. The last member of the list should be the document element.
Returns true if the current element is an ancestor of the descendant element.
Return true if the crrent element is the descendant of the ancestor element.
Returns a list of sibling elements.
Returns true if the elements has sibling elements.
Return a string containing the name (i.e. the type, not the Id) of an element.
Return a string containing the elements Id (unique identifier string).
Returns the specified attribute in the element, will return a serialised string instead of posible attribute object if serialise set.
Returns a list of attributes in various forms.
Returns a list of attribute names, used internaly.
Returns true if this element as this attribute.
Returns true if this attribute in this namespace is in this element.
Return true is element has any attributes
Set an attribute on this element, it will accept serialised strings or objects.
Remove a single attribute from this element.
Returns an attributes namespace in this element.
Sets an attributes namespace in this element.
Rerieve and set this elements cdata (non tag cdata form)
Return true if this element has cdata.
Return this elements document, returns undef if no document available.
Inserts a new element just before the referenced child.
Inserts a new child element just after the referenced child.
Inserts the child just after the current element (effects parent).
Inserts the child just before the current element (effects parent).
Replace an old child with a new element, returns old element.
Replace an old element with a new element in the parents context; element becomes orphaned.
Remove a child from this element, returns the orphaned element.
Removes this element from it's parent; element becomes orphaned.
Adds the new child to the end of this elements children list.
Clones the current element, deep allows all child elements to be cloned. The new element is an orphan with all the same id's and atributes as this element.
Scans through children trying to find this child in the list.
Adds the new child at the specified index to this element.
Removed the child at index and returns the now orphaned element.
Not DOM2, creates a child element, appending to current element.
The advantage to using this method is the elements created with $document->createElement create basic element objects or base objects (those specified in the XML base class or it's kin) Elements created with this could offer more complex objects back.
Example: an SVG Gradiant will have stop elements under it, creating stop elements with $document->createElement will return an XML::DOM2::Element create a stop element with $element->createChildElement and it will return an SVG2::Element::Gradiant::Stop object (although both would output the same xml) and it would also prevent you from creating invalid child elements such as a group within a text element.
$element->createChildElement($name, %opts);
Martin Owens, doctormo@postmaster.co.uk
perl(1), XML::DOM2, XML::DOM2::Element
http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core.html DOM at the W3C
To install XML::DOM2, copy and paste the appropriate command in to your terminal.
cpanm
cpanm XML::DOM2
CPAN shell
perl -MCPAN -e shell install XML::DOM2
For more information on module installation, please visit the detailed CPAN module installation guide.