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:)...Here's the tidied XML:#!/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; }
Update: fixed typo<?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>
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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |