#!/usr/bin/perl -T -I../lib/ use Test::More tests => 12; use strict; BEGIN { use_ok( 'XML::DOM2' ); } my $xml_data = " value1 value2 value3 value41 value42 value43 "; my $doc = XML::DOM2->new( data => $xml_data ); my $tag1 = $doc->getElementById( 'foo' ); my $tag2 = $doc->getElementById( 'bar' ); ok( $tag1, 'Get element by Id' ); ok( (not $tag2), 'Fail to get wrong element' ); ok( $tag1->localName() eq 'child1', 'Element tag local name' ); my $sibling = $tag1->getNextSibling(); ok( $sibling, 'Get next sibling' ); ok( $sibling->localName() eq 'child2', 'Sibling tag name' ); my $child = $sibling->getFirstChild(); ok( $child, 'Get first child' ); ok( $child->localName() eq 'child21', 'Child tag name' ); my $attr = $child->getAttribute( 'attributeB' ); ok( $attr, 'Load Attribute from element' ); ok( $attr->value() eq 'valueB', 'Attribute value' ); ok( $attr eq 'valueB', 'Attribute Overloaded' ); ok( $child->cdata()->text() eq 'value2', 'Element cdata contents' ); exit 0;