Perl Module XML::Node

Chang Liu

Nov 1999

Revision History
Revision 0.0915 Nov 1999
--Add support to attributes
Revision 0.064 Nov 1999
--Change to an object class
Revision 0.0420 Oct 1999
--The first version that's submitted to CPAN.



XML::Node is for those who use Perl to process XML files. XML::Node is built on top of XML::Parser and provides a simplified programming interface. XML::Node users can register callback sub-routines or variables to specific type of XML nodes. The values of the specified XML nodes are automatically copied to the corresponding variables. When specified XML tags are found, registered callback sub-routines are called. XML::Node is a shortcut to XML::Parser if you don't care much about details of XML files.

Here is an example. This XML file contains order information:

Example 1. orders.xml

    <Item>A Book</Item>
   <TagsThatIDontCare>Blah Blah</TagsThatIDontCare>
This simple Perl script can parse the XML file and print out all the orders.

Example perl.

use XML::Node;

my $item = "";
my $quantity = "";

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

$p->register(">Orders>Order>Item","char" => \$item);
$p->register(">Orders>Order>Quantity","char" => \$quantity);
$p->register(">Orders>Order","end" => \&handle_order_end);

print "Processing file [orders.xml]...\n";

sub handle_order_end
    print "Found order -- Item: [$item] Quantity: [$quantity]\n";
    $item = "";
    $quantity = "";

Bug Report

Please submit any related bugs, issues, suggestions, or comments to