.\" Automatically generated by Pod::Man 4.11 (Pod::Simple 3.35) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "SVG::DOM 3pm" .TH SVG::DOM 3pm "2020-07-05" "perl v5.30.3" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" SVG::DOM \- A library of DOM (Document Object Model) methods for SVG objects. .SH "SUMMARY" .IX Header "SUMMARY" \&\s-1SVG::DOM\s0 provides a selection of methods for accessing and manipulating \s-1SVG\s0 elements through DOM-like methods such as getElements, getChildren, getNextSibling and so on. .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 2 \& my $svg=SVG\->new(id=>"svg_dom_synopsis", width=>"100", height=>"100"); \& my %attributes=$svg\->getAttributes; \& \& my $group=$svg\->group(id=>"group_1"); \& my $name=$group\->getElementName; \& my $id=$group\->getElementID; \& \& $group\->circle(id=>"circle_1", cx=>20, cy=>20, r=>5, fill=>"red"); \& my $rect=$group\->rect(id=>"rect_1", x=>10, y=>10, width=>20, height=>30); \& my $width=$rect\->getAttribute("width"); \& \& my $has_children=$group\->hasChildren(); \& my @children=$group\->getChildren(); \& \& my $kid=$group\->getFirstChild(); \& do { \& print $kid\->xmlify(); \& } while ($kid=$kid\->getNextSibling); \& \& my @ancestors=$rect\->getParents(); \& my $is_ancestor=$group\->isAncestor($rect); \& my $is_descendant=$rect\->isDescendant($svg); \& \& my @rectangles=$svg\->getElements("rect"); \& my $allelements_arrayref=$svg\->getElements(); \& \& $group\->insertBefore($newChild,$rect); \& $group\->insertAfter($newChild,$rect); \& $rect = $group\->replaceChild($newChild,$rect); \& $group\->removeChild($newChild); \& my $newRect = $rect\->cloneNode($deep); \& \& ...and so on... .Ve .SH "METHODS" .IX Header "METHODS" .ie n .SS "@elements = $obj\->getElements($element_name)" .el .SS "\f(CW@elements\fP = \f(CW$obj\fP\->getElements($element_name)" .IX Subsection "@elements = $obj->getElements($element_name)" Return a list of all elements with the specified name (i.e. type) in the document. If no element name is provided, returns a list of all elements in the document. In scalar context returns an array reference. .ie n .SS "@children = $obj\->\fBgetChildren()\fP" .el .SS "\f(CW@children\fP = \f(CW$obj\fP\->\fBgetChildren()\fP" .IX Subsection "@children = $obj->getChildren()" Return a list of all children defined on the current node, or undef if there are no children. In scalar context returns an array reference. .PP Alias: \fBgetChildElements()\fR, \fBgetChildNodes()\fR .ie n .SS "@children = $obj\->\fBhasChildren()\fP" .el .SS "\f(CW@children\fP = \f(CW$obj\fP\->\fBhasChildren()\fP" .IX Subsection "@children = $obj->hasChildren()" Return 1 if the current node has children, or 0 if there are no children. .PP Alias: hasChildElements, \fBhasChildNodes()\fR .ie n .SS "$ref = $obj\->\fBgetFirstChild()\fP" .el .SS "\f(CW$ref\fP = \f(CW$obj\fP\->\fBgetFirstChild()\fP" .IX Subsection "$ref = $obj->getFirstChild()" Return the first child element of the current node, or undef if there are no children. .ie n .SS "$ref = $obj\->\fBgetLastChild()\fP" .el .SS "\f(CW$ref\fP = \f(CW$obj\fP\->\fBgetLastChild()\fP" .IX Subsection "$ref = $obj->getLastChild()" Return the last child element of the current node, or undef if there are no children. .ie n .SS "$ref = $obj\->\fBgetSiblings()\fP" .el .SS "\f(CW$ref\fP = \f(CW$obj\fP\->\fBgetSiblings()\fP" .IX Subsection "$ref = $obj->getSiblings()" Return a list of all children defined on the parent node, containing the current node. .ie n .SS "$ref = $obj\->\fBgetNextSibling()\fP" .el .SS "\f(CW$ref\fP = \f(CW$obj\fP\->\fBgetNextSibling()\fP" .IX Subsection "$ref = $obj->getNextSibling()" Return the next child element of the parent node, or undef if this is the last child. .ie n .SS "$ref = $obj\->\fBgetPreviousSibling()\fP" .el .SS "\f(CW$ref\fP = \f(CW$obj\fP\->\fBgetPreviousSibling()\fP" .IX Subsection "$ref = $obj->getPreviousSibling()" Return the previous child element of the parent node, or undef if this is the first child. .ie n .SS "$index = $obj\->\fBgetChildIndex()\fP" .el .SS "\f(CW$index\fP = \f(CW$obj\fP\->\fBgetChildIndex()\fP" .IX Subsection "$index = $obj->getChildIndex()" Return the place of this element in the parent node's list of children, starting from 0. .ie n .SS "$element = $obj\->getChildAtIndex($index)" .el .SS "\f(CW$element\fP = \f(CW$obj\fP\->getChildAtIndex($index)" .IX Subsection "$element = $obj->getChildAtIndex($index)" Returns the child element at the specified index in the parent node's list of children. .ie n .SS "$ref = $obj\->\fBgetParentElement()\fP" .el .SS "\f(CW$ref\fP = \f(CW$obj\fP\->\fBgetParentElement()\fP" .IX Subsection "$ref = $obj->getParentElement()" Return the parent of the current node. .PP Alias: \fBgetParent()\fR .ie n .SS "@refs = $obj\->\fBgetParentElements()\fP" .el .SS "\f(CW@refs\fP = \f(CW$obj\fP\->\fBgetParentElements()\fP" .IX Subsection "@refs = $obj->getParentElements()" Return a list of the parents of the current node, starting from the immediate parent. The last member of the list should be the document element. .PP Alias: \fBgetParents()\fR .ie n .SS "$name = $obj\->\fBgetElementName()\fP" .el .SS "\f(CW$name\fP = \f(CW$obj\fP\->\fBgetElementName()\fP" .IX Subsection "$name = $obj->getElementName()" Return a string containing the name (i.e. the type, not the \s-1ID\s0) of an element. .PP Alias: \fBgetType()\fR, \fBgetTagName()\fR, \fBgetNodeName()\fR .ie n .SS "$ref = $svg\->getElementByID($id)" .el .SS "\f(CW$ref\fP = \f(CW$svg\fP\->getElementByID($id)" .IX Subsection "$ref = $svg->getElementByID($id)" Alias: \fBgetElementbyID()\fR .PP Return a reference to the element which has \s-1ID\s0 \f(CW$id\fR, or undef if no element with this \s-1ID\s0 exists. .ie n .SS "$id = $obj\->\fBgetElementID()\fP" .el .SS "\f(CW$id\fP = \f(CW$obj\fP\->\fBgetElementID()\fP" .IX Subsection "$id = $obj->getElementID()" Return a string containing the \s-1ID\s0 of the current node, or undef if it has no \s-1ID.\s0 .ie n .SS "$ref = $obj\->\fBgetAttributes()\fP" .el .SS "\f(CW$ref\fP = \f(CW$obj\fP\->\fBgetAttributes()\fP" .IX Subsection "$ref = $obj->getAttributes()" Return a hash reference of attribute names and values for the current node. .ie n .SS "$value = $obj\->getAttribute($name);" .el .SS "\f(CW$value\fP = \f(CW$obj\fP\->getAttribute($name);" .IX Subsection "$value = $obj->getAttribute($name);" Return the string value attribute value for an attribute of name \f(CW$name\fR. .ie n .SS "$ref = $obj\->setAttributes({name1=>$value1,name2=>undef,name3=>$value3})" .el .SS "\f(CW$ref\fP = \f(CW$obj\fP\->setAttributes({name1=>$value1,name2=>undef,name3=>$value3})" .IX Subsection "$ref = $obj->setAttributes({name1=>$value1,name2=>undef,name3=>$value3})" Set a set of attributes. If \f(CW$value\fR is undef, deletes the attribute. .ie n .SS "$value = $obj\->setAttribute($name,$value);" .el .SS "\f(CW$value\fP = \f(CW$obj\fP\->setAttribute($name,$value);" .IX Subsection "$value = $obj->setAttribute($name,$value);" Set attribute \f(CW$name\fR to \f(CW$value\fR. If \f(CW$value\fR is undef, deletes the attribute. .ie n .SS "$cdata = $obj\->\fBgetCDATA()\fP" .el .SS "\f(CW$cdata\fP = \f(CW$obj\fP\->\fBgetCDATA()\fP" .IX Subsection "$cdata = $obj->getCDATA()" Return the canonical data (i.e. textual content) of the current node. .PP Alias: \fBgetCdata()\fR, \fBgetData()\fR .ie n .SS "$boolean = $obj\->isAncestor($element)" .el .SS "\f(CW$boolean\fP = \f(CW$obj\fP\->isAncestor($element)" .IX Subsection "$boolean = $obj->isAncestor($element)" Returns 1 if the current node is an ancestor of the specified element, otherwise 0. .ie n .SS "$boolean = $obj\->isDescendant($element)" .el .SS "\f(CW$boolean\fP = \f(CW$obj\fP\->isDescendant($element)" .IX Subsection "$boolean = $obj->isDescendant($element)" Returns 1 if the current node is a descendant of the specified element, otherwise 0. .ie n .SS "$boolean = $obj\->insertBefore( $element, $child );" .el .SS "\f(CW$boolean\fP = \f(CW$obj\fP\->insertBefore( \f(CW$element\fP, \f(CW$child\fP );" .IX Subsection "$boolean = $obj->insertBefore( $element, $child );" Returns 1 if \f(CW$element\fR was successfully inserted before \f(CW$child\fR in \f(CW$obj\fR .ie n .SS "$boolean = $obj\->insertAfter( $element, $child );" .el .SS "\f(CW$boolean\fP = \f(CW$obj\fP\->insertAfter( \f(CW$element\fP, \f(CW$child\fP );" .IX Subsection "$boolean = $obj->insertAfter( $element, $child );" Returns 1 if \f(CW$element\fR was successfully inserted after \f(CW$child\fR in \f(CW$obj\fR .ie n .SS "$boolean = $obj\->insertSiblingBefore( $element );" .el .SS "\f(CW$boolean\fP = \f(CW$obj\fP\->insertSiblingBefore( \f(CW$element\fP );" .IX Subsection "$boolean = $obj->insertSiblingBefore( $element );" Returns 1 if \f(CW$element\fR was successfully inserted before \f(CW$obj\fR .ie n .SS "$boolean = $obj\->insertSiblingAfter( $element );" .el .SS "\f(CW$boolean\fP = \f(CW$obj\fP\->insertSiblingAfter( \f(CW$element\fP );" .IX Subsection "$boolean = $obj->insertSiblingAfter( $element );" Returns 1 if \f(CW$element\fR was successfully inserted after \f(CW$obj\fR .ie n .SS "$element = $obj\->replaceChild( $element, $child );" .el .SS "\f(CW$element\fP = \f(CW$obj\fP\->replaceChild( \f(CW$element\fP, \f(CW$child\fP );" .IX Subsection "$element = $obj->replaceChild( $element, $child );" Returns \f(CW$child\fR if \f(CW$element\fR successfully replaced \f(CW$child\fR in \f(CW$obj\fR .ie n .SS "$element = $obj\->removeChild( $child );" .el .SS "\f(CW$element\fP = \f(CW$obj\fP\->removeChild( \f(CW$child\fP );" .IX Subsection "$element = $obj->removeChild( $child );" Returns \f(CW$child\fR if it was removed successfully from \f(CW$obj\fR .ie n .SS "$element = $obj\->cloneNode( $deep );" .el .SS "\f(CW$element\fP = \f(CW$obj\fP\->cloneNode( \f(CW$deep\fP );" .IX Subsection "$element = $obj->cloneNode( $deep );" Returns a new \f(CW$element\fR clone of \f(CW$obj\fR, without parents or children. If deep is set to 1, all children are included recursively. .SH "AUTHOR" .IX Header "AUTHOR" Ronan Oger, ronan@roitsystems.com Martin Owens, doctormo@postmaster.co.uk .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fBperl\fR\|(1), \s-1SVG\s0, \s-1SVG::XML\s0, SVG::Element, SVG::Parser .PP \s-1SVG\s0 at the W3C