=head1 NAME

XML::LibXML::Document - DOM Document Class

=head1 SYNOPSIS

  use XML::LibXML::Document;

  $dom = XML::LibXML::Document->new( $version, $encoding );
  $dom = XML::LibXML::Document->createDocument( $version, $encoding );
  $strEncoding = $doc->getEncoding();
  $strVersion = $doc->getVersion();
  $bool = $doc->isEqual( $other_doc );
  $docstring = $dom->toString([$format]);
  $bool = $dom->is_valid();
  $root = $dom->getDocumentElement($name, $namespace );
  $dom->setDocumentElement( $root );
  $element = $dom->createElement( $nodename );
  $text = $dom->createTextNode( $content_text );
  $comment = $dom->createComment( $comment_text );
  $cdata = $dom->create( $cdata_content );

=head1 DESCRIPTION

The Document Class is the result of a parsing process. But
sometimes it is needed, to create a Document from scratch. The
provides functions that are conform to the DOM Core naming
style.
It is suggested, allways to create a node unbound of a document.
There is no need of really including the node to the document, but
since the node is once bound to a document, it is quite save that
all strings have the correct encoding. If an unbound textnode with
an iso encoded string is created (e.g. with $CLASS->new()), the
I<toString> function may not return the expected result.
This seems like a limitation as long UTF8 encoding is ashured. If
iso encoded strings come into play it is much saver to use the
node creation functions of B<XML::LibXML::Document>.

=head2 Methods

=over 4

=item B<new>

alias for createDocument()

=item B<createDocument>

The constructor for the document class. As Parameter it takes
the version string and (optionally) the ecoding string.
Simply calling B<createDocument> will create the document:

  
  <?xml version="your version" encoding="your encoding"?>


Both parameter are optional. The default value for B<$version> is I<1.0> , of course. If the B<$encoding> parameter is not set,
the encoding will be left unset, which means UTF8 is implied.
The parameter less call of B<createDocument> wil result the following code:

  
  <?xml version="1.0"?>


=item B<getEncoding>

returns the encoding string of the document

=item B<getVersion>

returns the version string of the document

=item B<isEqual>

returns TRUE (1) if documents refer to the same documentstructure,
otherwise FALSE (0) is returned.

=item B<toString>

B<toString> is a deparsing function, so the DOM Tree can
be translated into a string, ready for output.
The optional B<$format> parameter sets the indenting of the output. This parameter is expected to be an I<integer> value,
that specifies the number of linebreaks for each node.
For more information about the formatted output check the documentation
of I<xmlDocDumpFormatMemory> in I<libxml2/tree.h> .

=item B<is_valid>

Returns either TRUE or FALSE depending on the DOM Tree is a
valid Document or not.

=item B<getDocumentElement>

Returns the root element of the Document. A document can have
just one root element to contain the documents data.

=item B<setDocumentElement>

This function enables you to set the root element for a
document. The function supports the import of a node from a
different document tree.

=item B<createElement>

This function creates a new Element Node bound to the DOM with
the name I<$nodename> .

=item B<createTextNode>

As an equivalent of B<createElement> , but it creates a B<Text Node> bound to the DOM.

=item B<createComment>

As an equivalent of B<createElement> , but it creates a B<Comment Node> bound to the DOM.

=item B<createCDATASection>

Similar to createTextNode and createComment, this function creates a CDataSection bound to the current DOM.

=back

=head1 SEE ALSO

XML::LibXML, XML::LibXML::Element, XML::LibXML::Text, XML::LibXML::Comment

=head1 VERSION

0.90_a

