File: 01_parse.t

package info (click to toggle)
libxml-treepp-perl 0.33-1.1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 456 kB
  • ctags: 41
  • sloc: perl: 745; xml: 58; makefile: 45; sh: 30
file content (21 lines) | stat: -rwxr-xr-x 773 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# ----------------------------------------------------------------
    use strict;
    use Test::More tests => 4;
    BEGIN { use_ok('XML::TreePP') };
# ----------------------------------------------------------------
    my $tpp = XML::TreePP->new();
    my $source = '<root attr="AAA">BBB</root>';
    my $tree = $tpp->parse( $source );

    is( $tree->{root}->{"#text"}, "BBB", "text node" );
    is( $tree->{root}->{"-attr"}, "AAA", "attributes" );

    my $back = $tpp->write( $tree );
    my $test = $source;
    $back =~ s/\s+//sg;
    $back =~ s/<\?.*?\?>//s;
    $test =~ s/\s+//sg;
    is( $test, $back, "parse and write" );
# ----------------------------------------------------------------
;1;
# ----------------------------------------------------------------