According to this post, findnodes() uses the full XPath engine. Also, I noticed that the use of position selectors like range[1] isn't supported on twig_handlers or twig_roots.

Since you're dealing with a very, very small XML, I tried this and returned both rangeStartTimes. I cheated:)...
#!/usr/bin/perl -l use strict; use warnings; use XML::Twig::XPath; $|=1; my $file = '/root/Desktop/bitrate.xml'; my $twig = XML::Twig::XPath->new( twig_roots => { "//range/rangeStartTime" => \&update }); $twig->parsefile($file); sub update { my ($twig, $server) = @_; print $server->text; }
Here's the tidied XML:
<?xml version="1.0" encoding="UTF-8"?> <bitrate name="1000"> <track type="V"> <range> <rangeStartTime>1261287</rangeStartTime> <rangeEndTime>1324271</rangeEndTime> </range> <range> <rangeStartTime>1324282</rangeStartTime> <rangeEndTime>0.000</rangeEndTime> </range> </track> </bitrate>
Update: fixed typo

In reply to Re^3: XML::Twig - Using xpath with twig roots by Khen1950fx
in thread XML::Twig - Using xpath with twig roots by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.