The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.


  XML::DOM2 - DOM controlled, strict XML module for extentable xml objects.


Version 0.06 - 2007-11-28


  my $xml = XML::DOM2->new( file => 'filename.xml' );
  my $xml = XML::DOM2->new( data => '<xml>data</xml>' );
  my $xml = XML::DOM2->new( fh   => $file_handle );



  XML::DOM2 is yet _another_ perl XML module.


  * DOM Level2 Compilence in both document, elements and attributes
  * NameSpace control for elements and attributes
  * XPath (it's just one small method once you have a good DOM)
  * Extendability:
   * Document, Element or Attribute classes can be used as base class for other
         kinds of document, element or attribute.
   * Element and Attribute Handler allows element specific child elements and attribute objects.
   * Element and Attribute serialisation overiding.
  * Parsing with SAX (use XML::SAX::PurePerl for low dependancy installs)
  * Internal serialisation


$class->new( file|data|fh )

  Create a new xml object, it will parse a file, data or a file handle if required or will await creation of nodes.

$object->parseDocument( %p )

  Parse existing xml data into a document, inputs taken from ->new;

$object->xmlify( %options ) =head2 $object->render( %options ) =head2 $object->to_xml( %options ) =head2 $object->serialise( %options ) =head2 $object->serialize( %options )

  Returns xml representation of xml document.

        seperator - default is carage return

$class->adaptation( $name, $structure )

  Convert a perl structure and create a new xml document of it:

        $class->adaptation('xml', { foo => [ 'A', 'B', 'C' ], bar => 'D', kou => { 'A' => 1, 'B' => 2 } });

  Will convert to:


        $class->adaptation('xml', { 'foo' => [ { '+' => 'A', '_Letter' => '1' }, { '+' => 'B', '_Letter' => 2 } ] });

        Will convert to:

        "<xml><foo Letter="1">A</foo><foo Letter="2">B</foo></xml>"


  $extention = $xml->extention();

  Does not work, legacy option maybe enabled in later versions.


$object->namespace( $set )

  Default document name space

$object->name( $set )

  Document localName


  Document Type object


  XML Version


  XML Encoding


 XML Standalone



$xml->_serialise_doctype( seperator => "\n" );

Returns the document type in an xml header form.


$xml->_serialise_extention( seperator => "\n" );

Returns the document extentions.


$xml->_serialise_header( );

The XML header, with version, encoding and standalone options.


$xml->_element_handle( $type, %element-options );

Returns an XML element based on $type, use to extentd element capabilties.

$object->_option( $name[, $data] )

  Set or get the required option.


  Does this node support element children.


  Returns the doctype name or 'xml' as default, can be extended.


  Returns the comment credit used in the output


Martin Owens,


Based on by Ronan Oger,