in reply to Re: XML::Twig how to find a parent's attribute
in thread XML::Twig how to find a parent's attribute

Thanks poj, though I should have mentioned, I won't always know that the ancestor is a p; it could be anything. Anyway to grab "whatever it is"?

  • Comment on Re^2: XML::Twig how to find a parent's attribute

Replies are listed 'Best First'.
Re^3: XML::Twig how to find a parent's attribute
by poj (Abbot) on Jul 26, 2014 at 05:19 UTC
    sub li { my ($t,$elt) = @_; my $e = $elt->parent('[@conref != ""]'); # p removed if ( defined $e ){ print $e->tag." ".$elt->text."\n"; } }
    poj