Ok, after finding that <a href="http://www.mirod.org/">http://www.mirod.org/</a> is the only remaining XML::Twig documentation site (after <a href="http://search.cpan.org/dist/XML-Twig/Twig_pm.slow">http://search.cpan.org/dist/XML-Twig/Twig_pm.slow</a>), I'm having trouble getting started.<div>

<br></div><div>(My XML file and some broken code is below.)</div><div><br></div><div>What I want to do is parse the XML file (around 300KB), and check the "time_of_last_rate_dp" section of each "instance" to compare with the check_starttime time in the beginning of the XML file.</div>

<div><br></div><div>I've got the simple code that can pull in the XML file, but I can't determine how to "walk" through the XML tree.  I thought I'd use the "findnodes()" or "children()" subroutines, but that's not quite it...</div>

<div><br></div><div>Anyone want to throw me some additional subroutines I need to grok?</div><div><br></div><div>Thanks,</div><div>Dan</div><div><br></div><div>=== begin code ===</div><div><div><font class="Apple-style-span" face="'courier new', monospace">#!perl -w</font></div>

<div><font class="Apple-style-span" face="'courier new', monospace">#</font></div><div><font class="Apple-style-span" face="'courier new', monospace"># Required modules:</font></div><div><font class="Apple-style-span" face="'courier new', monospace"># XML::Twig - perl -MCPAN -e "install XML::Twig"</font></div>

<div><font class="Apple-style-span" face="'courier new', monospace">#</font></div><div><font class="Apple-style-span" face="'courier new', monospace">use strict;</font></div><div><font class="Apple-style-span" face="'courier new', monospace">use XML::Twig;</font></div>

<div><font class="Apple-style-span" face="'courier new', monospace">my $filename = shift || die ("Must supply an XML file to parse.");</font></div><div><font class="Apple-style-span" face="'courier new', monospace">my $twig = XML::Twig->new(</font></div>

<div><font class="Apple-style-span" face="'courier new', monospace"><span class="Apple-tab-span" style="white-space:pre">                     </span>pretty_print => 'indented'</font></div><div><font class="Apple-style-span" face="'courier new', monospace"><span class="Apple-tab-span" style="white-space:pre">          </span>);</font></div>

<div><font class="Apple-style-span" face="'courier new', monospace"><br></font></div><div><font class="Apple-style-span" face="'courier new', monospace">$twig->parsefile($filename);</font></div><div><font class="Apple-style-span" face="'courier new', monospace">my $root = $twig->root;</font></div>

<div><font class="Apple-style-span" face="'courier new', monospace"><br></font></div><div><font class="Apple-style-span" face="'courier new', monospace"># twig->print works fine and regurgitates the whole XML file...</font></div>

<div><font class="Apple-style-span" face="'courier new', monospace">$twig->print;</font></div><div><font class="Apple-style-span" face="'courier new', monospace"><br></font></div><div><font class="Apple-style-span" face="'courier new', monospace"># This doesn't work...the "$instance" is a HASH.</font></div>

<div><font class="Apple-style-span" face="'courier new', monospace">foreach my $instance ($root->children('instance')) {</font></div><div><font class="Apple-style-span" face="'courier new', monospace"><span class="Apple-tab-span" style="white-space:pre"> </span>printf ("Found: $instance\n");</font></div>

<div><font class="Apple-style-span" face="'courier new', monospace">}</font></div></div><div>=== end code ===</div><div><br></div><div>Here is a portion of the XML file:</div><div>=== begin XML ===</div><div><div>

<font class="Apple-style-span" face="'courier new', monospace"><collection_status></font></div><div><font class="Apple-style-span" face="'courier new', monospace">  <primary_server>10.10.10.11</primary_server></font></div>

<div><font class="Apple-style-span" face="'courier new', monospace">  <check_interval time="720">720</check_interval></font></div><div><font class="Apple-style-span" face="'courier new', monospace">  <check_starttime time="1307366104">06/06/11 09:15:04</check_starttime></font></div>

<div><font class="Apple-style-span" face="'courier new', monospace">  <check_endtime time="1307366110">06/06/11 09:15:10</check_endtime></font></div><div><font class="Apple-style-span" face="'courier new', monospace">  <instance></font></div>

<div><font class="Apple-style-span" face="'courier new', monospace">    <motype_id>42815</motype_id></font></div><div><font class="Apple-style-span" face="'courier new', monospace">    <motype_name>My MO Type name</motype_name></font></div>

<div><font class="Apple-style-span" face="'courier new', monospace">    <inst_id>119863</inst_id></font></div><div><font class="Apple-style-span" face="'courier new', monospace">    <device></font></div>

<div><font class="Apple-style-span" face="'courier new', monospace">        <device_id>545</device_id></font></div><div><font class="Apple-style-span" face="'courier new', monospace">        <device_name>My device name</device_name></font></div>

<div><font class="Apple-style-span" face="'courier new', monospace">    </device></font></div><div><font class="Apple-style-span" face="'courier new', monospace">    <agent></font></div><div><font class="Apple-style-span" face="'courier new', monospace">        <agent_id>10248</agent_id></font></div>

<div><font class="Apple-style-span" face="'courier new', monospace">        <agent_name>AABBCC (alpha)</agent_name></font></div><div><font class="Apple-style-span" face="'courier new', monospace">        <agent_status>Active</agent_status></font></div>

<div><font class="Apple-style-span" face="'courier new', monospace">    </agent></font></div><div><font class="Apple-style-span" face="'courier new', monospace">    <name>Test+%28GOOGLE%29</name></font></div>

<div><font class="Apple-style-span" face="'courier new', monospace">    <collect>TRUE</collect></font></div><div><font class="Apple-style-span" face="'courier new', monospace">    <config>300</config></font></div>

<div><font class="Apple-style-span" face="'courier new', monospace">    <time_of_last_rate_dp time="0">1969/12/31 16:00:00</time_of_last_rate_dp></font></div><div><font class="Apple-style-span" face="'courier new', monospace">  </instance></font></div>

<div><font class="Apple-style-span" face="'courier new', monospace">  <instance></font></div><div><font class="Apple-style-span" face="'courier new', monospace">    <motype_id>28451</motype_id></font></div>

<div><font class="Apple-style-span" face="'courier new', monospace">    <motype_name>HPUX FileSystem</motype_name></font></div><div><font class="Apple-style-span" face="'courier new', monospace">    <inst_id>25251</inst_id></font></div>

<div><font class="Apple-style-span" face="'courier new', monospace">    <device></font></div><div><font class="Apple-style-span" face="'courier new', monospace">        <device_id>34</device_id></font></div>

<div><font class="Apple-style-span" face="'courier new', monospace">        <device_name>NEHPX001</device_name></font></div><div><font class="Apple-style-span" face="'courier new', monospace">    </device></font></div>

<div><font class="Apple-style-span" face="'courier new', monospace">    <agent></font></div><div><font class="Apple-style-span" face="'courier new', monospace">        <agent_id>10033</agent_id></font></div>

<div><font class="Apple-style-span" face="'courier new', monospace">        <agent_name>NEHPX001</agent_name></font></div><div><font class="Apple-style-span" face="'courier new', monospace">        <agent_status>Active</agent_status></font></div>

<div><font class="Apple-style-span" face="'courier new', monospace">    </agent></font></div><div><font class="Apple-style-span" face="'courier new', monospace">    <name>%2Foracle%2FEPP%2Foraarch</name></font></div>

<div><font class="Apple-style-span" face="'courier new', monospace">    <collect>TRUE</collect></font></div><div><font class="Apple-style-span" face="'courier new', monospace">    <config>300</config></font></div>

<div><font class="Apple-style-span" face="'courier new', monospace">    <time_of_last_rate_dp time="0">1969/12/31 16:00:00</time_of_last_rate_dp></font></div><div><font class="Apple-style-span" face="'courier new', monospace">  </instance></font></div>

<div><font class="Apple-style-span" face="'courier new', monospace"></collection_status></font></div><div>=== end XML ===</div><br>-- <br>***************** ************* *********** ******* ***** *** **<br>
"Quis custodiet ipsos custodes?"<br>
    (Who can watch the watchmen?)<br>    -- from the Satires of Juvenal<br>"I do not fear computers, I fear the lack of them."<br>    -- Isaac Asimov (Author)<br>** *** ***** ******* *********** ************* *****************<br>


</div>