slugger415 has asked for the wisdom of the Perl Monks concerning the following question:
Hello Monks, I've been looking through the Monks site and other resources for answers but haven't come up with anything. (xmltwig.com seems to have disappeared.)
I'm looking for a way to delete an XML tag without deleting its contents. For example, I have this:
<li> <p> Some <b>text</b> </p> </li>
And I want it to be just:
<li> Some <b>text</b> </li>I tried this but I get an error ("cannot paste an element that belongs to a tree"):
if($p->parent('li')){
my(@children) = $p->children;
$p->delete;
foreach my $c (@children){
$c->paste;
}
}
Forgive me as I'm a newbie at Twig and am still trying to figure out how it works.
Many thanks, Scott
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: XML::Twig removing tags from content (XML::Twig)
by toolic (Bishop) on Sep 26, 2011 at 17:07 UTC | |
by slugger415 (Monk) on Sep 26, 2011 at 19:52 UTC | |
by slugger415 (Monk) on Sep 26, 2011 at 22:27 UTC | |
|
Re: XML::Twig removing tags from content
by Jenda (Abbot) on Sep 26, 2011 at 18:32 UTC | |
|
Re: XML::Twig removing tags from content
by mirod (Canon) on Sep 27, 2011 at 07:49 UTC | |
by slugger415 (Monk) on Sep 28, 2011 at 18:15 UTC | |
|
Re: XML::Twig removing tags from content
by choroba (Cardinal) on Sep 27, 2011 at 13:37 UTC | |
|
Re: XML::Twig removing tags from content
by Lotus1 (Vicar) on Sep 27, 2011 at 16:56 UTC |