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

What do you intend {Title[@Name= "$filtername"] => 1} to do? @Name is an array, but it does not appear in the code fragment except here. I suspect it is not declared anywhere, and doesn't seem to make sense here in any case.


Perl is Huffman encoded by design.

Replies are listed 'Best First'.
Re^4: XML::Twig Question
by ramya2005 (Scribe) on Aug 15, 2005 at 23:20 UTC
    I am specifying 'attribute_condition' as it is specified in the XML::Twig document.
    tag[@att="val"]
    ?? Is my understanding about the usage is wrong?

      I can't make a lot of sense of the documentation either. However the following code may help:

      use warnings; use strict; use XML::Twig; my $filtername = 'Advanced Perl Programming'; my $books_tree= new XML::Twig(twig_roots => {Title => \&FixName}); $books_tree->parse(join "", <DATA>); #$books_tree->set_att(Name => 'Advanced Perl'); sub FixName { my ($p1, $p2) = @_; my %node = %$p2; print $node{"att"}{"Name"}."\n"; }

      Perl is Huffman encoded by design.