GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages


Manual Reference Pages  -  SVG::DOM (3)

.ds Aq ’

NAME

SVG::DOM - A library of DOM (Document Object Model) methods for SVG objects.

CONTENTS

SUMMARY

SVG::DOM provides a selection of methods for accessing and manipulating SVG elements through DOM-like methods such as getElements, getChildren, getNextSibling and so on.

SYNOPSIS



    my $svg=new SVG(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...



METHODS

CW@elements = CW$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.

CW@children = CW$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.

Alias: getChildElements(), getChildNodes()

CW@children = CW$obj->hasChildren()

Return 1 if the current node has children, or 0 if there are no children.

Alias: hasChildElements, hasChildNodes()

CW$ref = CW$obj->getFirstChild()

Return the first child element of the current node, or undef if there are no children.

CW$ref = CW$obj->getLastChild()

Return the last child element of the current node, or undef if there are no children.

CW$ref = CW$obj->getSiblings()

Return a list of all children defined on the parent node, containing the current node.

CW$ref = CW$obj->getNextSibling()

Return the next child element of the parent node, or undef if this is the last child.

CW$ref = CW$obj->getPreviousSibling()

Return the previous child element of the parent node, or undef if this is the first child.

CW$index = CW$obj->getChildIndex()

Return the place of this element in the parent node’s list of children, starting from 0.

CW$element = CW$obj->getChildAtIndex($index)

Returns the child element at the specified index in the parent node’s list of children.

CW$ref = CW$obj->getParentElement()

Return the parent of the current node.

Alias: getParent()

CW@refs = CW$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.

Alias: getParents()

CW$name = CW$obj->getElementName()

Return a string containing the name (i.e. the type, not the ID) of an element.

Alias: getType(), getTagName(), getNodeName()

CW$ref = CW$svg->getElementByID($id)

Alias: getElementbyID()

Return a reference to the element which has ID $id, or undef if no element with this ID exists.

CW$id = CW$obj->getElementID()

Return a string containing the ID of the current node, or undef if it has no ID.

CW$ref = CW$obj->getAttributes()

Return a hash reference of attribute names and values for the current node.

CW$value = CW$obj->getAttribute($name);

Return the string value attribute value for an attribute of name $name.

CW$ref = CW$obj->setAttributes({name1=>$value1,name2=>undef,name3=>$value3})

Set a set of attributes. If $value is undef, deletes the attribute.

CW$value = CW$obj->setAttribute($name,$value);

Set attribute $name to $value. If $value is undef, deletes the attribute.

CW$cdata = CW$obj->getCDATA()

Return the cannonical data (i.e. textual content) of the current node.

Alias: getCdata(), getData()

CW$boolean = CW$obj->isAncestor($element)

Returns 1 if the current node is an ancestor of the specified element, otherwise 0.

CW$boolean = CW$obj->isDescendant($element)

Returns 1 if the current node is a descendant of the specified element, otherwise 0.

CW$boolean = CW$obj->insertBefore( CW$element, CW$child );

Returns 1 if $element was successfully inserted before $child in $obj

CW$boolean = CW$obj->insertAfter( CW$element, CW$child );

Returns 1 if $element was successfully inserted after $child in $obj

CW$boolean = CW$obj->insertSiblingBefore( CW$element );

Returns 1 if $element was successfully inserted before $obj

CW$boolean = CW$obj->insertSiblingAfter( CW$element );

Returns 1 if $element was successfully inserted after $obj

CW$element = CW$obj->replaceChild( CW$element, CW$child );

Returns $child if $element successfully replaced $child in $obj

CW$element = CW$obj->removeChild( CW$child );

Returns $child if it was removed successfully from $obj

CW$element = CW$obj->cloneNode( CW$deep );

Returns a new $element clone of $obj, without parents or children. If deep is set to 1, all children are included recursively.

AUTHOR

Ronan Oger, ronan@roitsystems.com Martin Owens, doctormo@postmaster.co.uk

SEE ALSO

perl(1), SVG, SVG::XML, SVG::Element, SVG::Parser

<http://www.roitsystems.com/> ROIT Systems: Commercial SVG perl solutions <http://www.w3c.org/Graphics/SVG/> SVG at the W3C

Search for    or go to Top of page |  Section 3 |  Main Index


perl v5.20.3 SVG::DOM (3) 2016-03-17

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.