# phpman > perldoc > XML::Node

## NAME
    [XML::Node](https://www.chedong.com/phpMan.php/perldoc/XML%3A%3ANode/markdown) - Node-based XML parsing: a simplified interface to [XML::Parser](https://www.chedong.com/phpMan.php/perldoc/XML%3A%3AParser/markdown)

## SYNOPSIS
     use [XML::Node](https://www.chedong.com/phpMan.php/perldoc/XML%3A%3ANode/markdown);

     $xml_node = new [XML::Node](https://www.chedong.com/phpMan.php/perldoc/XML%3A%3ANode/markdown);
     $xml_node->register( $nodetype, $callback_type => \&callback_function );
     $xml_node->register( $nodetype, $callback_type => \$variable );

     open(FOO, 'xmlgenerator |');
     $p3->parse(*FOO);
     close(FOO);

     $xml_node->parsefile( $xml_filename );

## DESCRIPTION
    If you are only interested in processing certain nodes in an XML file, this module can help you
    simplify your Perl scripts significantly.

    The [XML::Node](https://www.chedong.com/phpMan.php/perldoc/XML%3A%3ANode/markdown) module allows you to register callback functions or variables for any XML node. If
    you register a call back function, it will be called when the nodes of the type you specified
    are encountered. If you register a variable, the content of a XML node will be appended to that
    variable automatically.

    Subroutine register accepts both absolute and relative node registrations.

    Here is an example of absolute path registration:

     1. register(">TestCase>Name", "start" => \&handle_TestCase_Name_start);

    Here are examples of single node name registration:

     2. register( "Name", "start" => \&handle_Name_start);
     3. register( "Name", "end"   => \&handle_Name_end);
     4. register( "Name", "char"  => \&handle_Name_char);

    Here is an example of attribute registration:

     5. register(">TestCase:Author", "attr" => \$testcase_author);

    Absolute path trigger condition is recommended because a "Name" tag could appear in different
    places and stands for different names.

    Example:

      1  <Testcase>
      2     <Name>Something</Name>
      3     <Oracle>
      4         <Name>Something</Name>
      5     </Oracle>
      6  </Testcase>

    Statement 1 causes &handle_TestCase_Name_start to be called when parsing Line 2. Statements
    2,3,4 cause the three handler subroutines to be called when parsing both Line 2 and Line 4.

    This module uses [XML::Parser](https://www.chedong.com/phpMan.php/perldoc/XML%3A%3AParser/markdown).

## EXAMPLE
    Examples "test.pl" and "parse_orders.pl" come with this perl module.

## SEE ALSO
    [XML::Parser](https://www.chedong.com/phpMan.php/perldoc/XML%3A%3AParser/markdown)

## NOTE
    When you register a variable, [XML::Node](https://www.chedong.com/phpMan.php/perldoc/XML%3A%3ANode/markdown) appends strings found to that variable. So please be
    sure to clear that variable before it is used again.

## AUTHORS
    Chang Liu <<liu@ics.uci.edu>>

## LAST MODIFIED
    $Date: 2001/12/10 11:38:28 $

