NAME
YAX::Document - A DOM document object for YAX
SYNOPSIS
use YAX::Document;
$xdoc = YAX::Document->new;
# set/get the doctype
$xdoc->doctype( $type );
$type = $xdoc->doctype;
# get the document element (root node)
$root = $xdoc->root;
$xdoc->set( $node_id => $element );
$xdoc->get( $node_id );
# the following should be used with care because the document can only
# have a single root element, so it doesn't make sense to append multiple
# elements to a document (although YAX doesn't stop you from doing so):
$xdoc->append( $new_child );
$xdoc->remove( $old_child );
$xdoc->replace( $new_child, $ref_child );
$xdoc->insert ( $new_child, $ref_child );
# creator methods:
$elmt = $xdoc->element( $name, %atts );
$text = $xdoc->text( $text );
$frag = $xdoc->fragment( @kids );
# stringify
$xstr = $xdoc->as_string();
DESCRIPTION
This module implements a document object for YAX which is returned by the parser, so you will generally not be constructing these by hand.
It also serves as a registry for nodes keyed on their `id' attribute.
A noteworthy difference between YAX and the W3C DOM is that nodes in a YAX tree do not keep a reference to the document in which they are found. However, the document can be accessed from a node if the node is a descendant of the document, as it is looked up dynamically by traversing up the ancestor chain.
SEE ALSO
YAX:Node, YAX::Text, YAX::Element, YAX::Fragment, YAX::Constants, YAX::Query
AUTHOR
Richard Hundt
LICENSE
This program is free software and may be modified and distributed under the same terms as Perl itself.