<?xml version="1.0" encoding="windows-1252"?>
<node id="996083" title="Re: How on earth do I use this script" created="2012-09-27 18:00:26" updated="2012-09-27 18:00:26">
<type id="11">
note</type>
<author id="879250">
remiah</author>
<data>
<field name="doctext">
&lt;p&gt;
Hello.&lt;br&gt;&lt;br&gt;

I tried this but I saw this script works just fine. How do you invoke the program? I did like this.
&lt;code&gt;
perl this_pg.pl target.xml SOMETHING 1
&lt;/code&gt;

With XML::Twig, similar things would go like this.
&lt;code&gt;
use strict;use warnings;
use XML::Twig;
my $xmlfile=$ARGV[0];
my $values_flag=$ARGV[0] || 0;

my $twig =XML::Twig-&gt;new( 
	twig_handlers =&gt; {'//*' =&gt; sub {
			my($twig,$elt)=@_;
			if ( $elt-&gt;descendants == 1 ){
				print $elt-&gt;path;
				print " := " . $elt-&gt;first_child_text if ( $values_flag );	
				print "\n";
			}
		}
	}, 
)-&gt;parsefile($xmlfile);
&lt;/code&gt;


&lt;/p&gt;</field>
<field name="root_node">
996071</field>
<field name="parent_node">
996071</field>
</data>
</node>
