NAME

DESCRIPTION

This module is used both as a base for YAX::Elememt, YAX::Text and YAX::Fragment. It is also partly mixed into YAX::Document.

It is also used to represent comment, cdata sections and processing instruction nodes.

METHODS

type()

Returns the type of the node as a number in a way analogous to the W3C DOM:

use YAX::Constants qw/:all/;

if ( $node->type == ELEMENT_NODE ) {
    ...
}
name()

If the node is an element node, then returns the tag name, otherwise returns a human readible string: '#text', '#document', '#processing-instruction', etc.

data( $new_val )

Used for text nodes, CDATA sections, processing instructions and declaration nodes to store the text values associated with them.

next()

Returns the next sibling if any.

prev()

Returns the previous sibling if any.

parent( $new_value )

Returns the parent node if any.

document()

Returns the document node ancestor of this node. Only works if this node is actually part of the tree (this is different to the W3C DOM where a node remains owned by a document after it is removed).

as_string()

Serializes this node. '""' is overloaded to call this method, so the following are equivalent:

my $xml_str = $node->as_string;
my $xml_str = "$node";

SEE ALSO

YAX:Element, YAX::Text, YAX::Fragment, YAX::Constants, YAX::Document

AUTHOR

Richard Hundt

LICENSE

This program is free software and may be modified and distributed under the same terms as Perl itself.