in reply to XML Parsing and Xpath confusion

I really like XML::Twig. Not sure what you are trying to do exactly but a basic example would be:

use strict; use warnings; use XML::Twig; my $t= XML::Twig->new( twig_handlers => { AMS => sub { print $_->{att}{Asset_Class}." has name ".$_->{att}{Asset_ +Name}."\n"; } })->parsefile('test.xml');

Output:

package has name xxxxxxxxxxxxxxxxxxxxxxxx_package title has name xxxxxxxxxxxxxxxxxxxxxxxx_title poster has name xxxxxxxxxxxxxxxxxxxxxxxx_poster movie has name xxxxxxxxxxxxxxxxxxxxxxxx_movie

Replies are listed 'Best First'.
Re^2: XML Parsing and Xpath confusion
by ikegami (Patriarch) on Jul 04, 2024 at 15:18 UTC

    The original tried to filter for just the posters, and it attempted to get the Metadata element. You get a different element, and you don't limit to just getting the element relating to the poster.

    (XML::Twig is also insanely slower.)