camelmanos has asked for the wisdom of the Perl Monks concerning the following question:

Hello and good day to all!

This is the full code:

#!/usr/bin/perl use XML::XPath; use XML::XPath::XMLParser; open (FILE, 'list.txt'); my @contents=<FILE>; close(FILE); foreach my $content (@contents) { if($content =~ m/(\d+)_(\d+)/) { $vid = $1; $xmlfile = "$vid.mp7.xml"; my $xp = XML::XPath->new(filename => $xmlfile); $var = '/Mpeg7/Description/MultimediaContent/Video/Tem +poralDecomposition/VideoSegment[@id="$content"]/MediaTime/MediaTimePo +int'; my $data = $xp->getNodeText($var); print "$data \n"; }; };

Actually, I found out what was going on by doing the obvious...I changes @id="content" for attribute::id="content" (unabbreviated syntax) and it worked fine...I don't know if it should be reported as a bug! Thanks anyway!

Replies are listed 'Best First'.
Re: First Question
by Corion (Patriarch) on Jan 14, 2009 at 10:12 UTC

    I'm confused as to whether the code you posted is supposed to run as is, because it contains syntactical and more subtle errors. But maybe you want to use XML::Twig. Or maybe you want to be more explicit in as to which part of your code posted is verbatim and which part is more hand wavy, otherwise, we can only give you hand wavy hints, like, "start with a simple XPath query and refine that until it stops working, then take out things until it starts working again", and "Start with a simple XML file".

Re: First Question
by DrHyde (Prior) on Jan 14, 2009 at 10:53 UTC
    You'll get more helpful responses if you choose a meaningful title for your post.