File: parse-foo.pl

package info (click to toggle)
libxml-node-perl 0.11-9
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 160 kB
  • ctags: 40
  • sloc: perl: 564; xml: 80; makefile: 5
file content (22 lines) | stat: -rw-r--r-- 740 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/usr/bin/perl -w
use XML::Node;

$xml_node = XML::Node->new();

$xml_node->register( "foo", 'char' => \$variable );
$xml_node->register( "foo>bar", "start" => sub { print "foo-bar[start](relative)\n" } );
$xml_node->register( "foo>bar", "end" => sub { print "foo-bar[end](relative)\n" } );
$xml_node->register( ">foo>bar", "end" => sub { print "foo-bar[end](absolute)\n" } );
$xml_node->register( ">foo:type", "attr" => sub { print "foo-type[attr](absolute)\n" } );
$xml_node->register( "foo:type", "attr" => sub { print "foo-type[attr](relative)\n" } );

my $file = "foo.xml";

print "Processing file [$file]...\n";

open(FOO, $file);
$xml_node->parse(*FOO);
close(FOO);

print "<foo> has content: [$variable]\n";