XML-Parser-Nodes
view release on metacpan or search on metacpan
t/XML-Parser-Nodes.t view on Meta::CPAN
my @tree = $xml->tree ;
is( @tree, 85, 'tree() #1' ) ;
my @grep = grep $_ eq 'catalog/book/title', @tree ;
is( @grep, 12, 'tree() #2' ) ;
@tree = $child->tree ;
is( @tree, 84, 'tree() #3' ) ;
my @node = $xml->nodebykey( $grep[0] ) ;
is( @node, 1, 'nodebykey() #1' ) ;
is( ref $node[0], $nodes, 'nodebykey() #2' ) ;
my @elements = $node[0]->childnodes ;
is( @elements, 0, 'nodebykey() #3' ) ;
like( $node[0]->gettext, qr/\S/, 'gettext() #1' ) ;
unlike( $child->gettext, qr/\S/, 'gettext() #2' ) ;
my @books = $child->childnodes ;
is( @books, 12, 'childnodes() #1' ) ;
is( ref $books[0], 'ARRAY', 'childnodes() #2' ) ;
is( $books[0][0], 'book', 'childnodes() #3' ) ;
is( ref $books[0][1], $nodes, 'childnodes() #4' ) ;
ok( exists $books[0][1]->getattributes->{id}, 'getattributes() #1' ) ;
my $recursion = $xml->getdata('catalog'
)->getdata('book'
)->getdata('price') ;
is( ref $recursion, $nodes, "recursion #1" ) ;
like( $recursion->gettext, qr/\S/, 'recursion #2' ) ;
my $header =<<'xml' ;
<?xml version="1.0"?>
xml
my $dump = $header .$xml->dump ;
is( $dump, $msmxml, "dump()" ) ;
my $xmlreq = XML::Parser::Nodes->pl2xml( $request ) ;
is( ($xmlreq->childnodes )[0]->[0], 'perldata', 'pl2xml() #1' ) ;
@tree = $xmlreq->tree ;
is( @tree, 33, 'pl2xml() #2' ) ;
$dump = $xmlreq->dump ;
my @match = ( '<arrayref memory_address="0x[0-9a-f]*">',
'<item key="RequestID">546696356386</item>',
'<MsgsRq>.*</MsgsRq>.*<MsgsRq>.*</MsgsRq>',
'<Ticket>gas8p9ee-re2s9old-ref2i6t</Ticket>',
) ;
like( $dump, qr/$match[0]/s, 'pl2xml() #3' ) ;
like( $dump, qr/$match[1]/s, 'pl2xml() #4' ) ;
$dump = $xmlreq->nvpdump ;
like( $dump, qr/$match[2]/s, 'nvpdump() #1' ) ;
like( $dump, qr/$match[3]/s, 'nvpdump() #2' ) ;
$xml = new XML::Parser::Nodes $msmxml ;
$dump = $header .$xml->dump ;
is( $dump, $msmxml, "new() #1" ) ;
my @path = split m|/|, $0 ;
pop @path ;
my $fn = join '/', @path, 'XML-Parser-Nodes.xml' ;
local( *H ) ;
my $fh = *H ;
ok( open( $fh, $fn ), 'can\'t open xml file' ) ;
my $buff = '' ;
do {
undef $/ ;
$buff = <$fh> ;
} ;
is( $buff, $msmxml, 'xml file contents' ) ;
$xml = $xmlpp->parsefile( $fn ) ;
$dump = $header .$xml->dump ;
is( $dump, $msmxml, "parsefile()" ) ;
$xml = new XML::Parser::Nodes $fn ;
$dump = $header .$xml->dump ;
is( $dump, $msmxml, "new() #2" ) ;
my $parent = $xml->wrapper('parent') ;
@list = $parent->childlist ;
is( @list, 1, 'wrapper() #1' ) ;
is( $list[0], 'parent', 'wrapper() #2' ) ;
@list = $parent->childnode( $list[0] )->childlist ;
is( @list, 1, 'wrapper() #3' ) ;
is( $list[0], 'catalog', 'wrapper() #4' ) ;
1
( run in 1.504 second using v1.01-cache-2.11-cpan-71847e10f99 )