OK, let's clear some misconceptions about XML::Twig with some explanations and a bit of code (I'll add this to the doc of the module for next version):

Now for something completely similar:

#!/bin/perl -w use strict; use XML::Twig; my $doc= '<doc> <l1> <l2> <e1>e1</e1> <e2>e2</e2> <e3>e3</e3> </l2> </l1> </doc>'; my $twig= new XML::Twig( twig_roots => { l2 => 1 } twig_handlers => { e2 => \&e2} ); $twig->parse( $doc); sub e2 { my( $t, $e2)= @_; print "ancestors: "; print map { $_->gi . " " } $e2->ancestors; # print l2 doc print "\n"; print "siblings: "; print $e2->prev_sibling->gi; # print e1 print " no next sibling\n" unless $e2->next_sibling; # e3 is not t +here yet print "purge!\n"; $t->purge; print "ancestors: "; print map { $_->gi . " " } $e2->ancestors; # print l2 doc (still + there) print "\n"; print "siblings: "; print " no prev sibling\n" unless $e2->prev_sibling; # e1 is gone print " no next sibling\n" unless $e2->next_sibling; # e3 is still + not there }

In reply to Re: Re: XML::Twig - can't find my uncle! by mirod
in thread XML::Twig - can't find my uncle! by DrSax

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.