Using Data::Dumper to print the results of tree-based parsing : Data « System Functions « Perl






Using Data::Dumper to print the results of tree-based parsing

   


#!/usr/bin/perl


use warnings;
use strict;
use Data::Dumper;
use XML::Parser;

my $xml =<<"DONE";
<letter><contact type = "from"><name>Tom</name>
   <phone>111-1234</phone></contact>
   <salutation format = "formal">Dear Sir:</salutation>
</letter>
DONE

my $parser = new XML::Parser( Style => 'Tree', ErrorContext => 2 );

my $tree = $parser->parse( $xml );

print( Data::Dumper->Dump( [ $tree ] ) );

   
    
    
  








Related examples in the same category

1.use Data::Dumper;
2.Using Data::Dumper to serialize the structure of a tree of XML document
3.Pass new variable name to Data::Dumper function
4.Use the Data:: Dumper function to output complex value
5.use Data Dumper to dump the reference