in reply to Re^2: XML::Twig Question
in thread XML::Twig Question

#! /usr/bin/perl -w use strict; use warnings; use XML::Twig; my $filtername = 'Advanced Perl Programming'; my $books_tree= new XML::Twig(); $books_tree->parsefile('books.xml'); my @title = $books_tree->get_xpath(qq[//Title[\@Name="$filtername"]]); $_->set_att(Name => 'Advanced Perl') for @title; $books_tree->print();

Step 1 - XPaths are strings, not perl data structures. Step 2 - I'm not too familiar with twig roots, so I load the entire data structure into memory, play with it, then print it back out. If you have a huge data structure that you want to stream, then we can start from here and move it back into twig roots that can parse/modify/output in a single statement, streaming and purging as you go.

Hope that helps.