2010-08-18 2 views

Répondre

1

Ceci est propre réponse Mak Killbers, écorchés de sa question à laquelle il appartient:


=== répondre à ma propre question ===

$ele->objectify_text(); 
    my @childNodes = $ele->content_list(); 
    for(my $j=0; $j < scalar(@childNodes); $j++) { 
     my $childNode = $childNodes[$j]; 
     if (ref($childNode) && ($childNode->tag() eq '~text')) { #TEXTNODE 
      my $newElement = HTML::Element->new('p'); 
      $newElement->push_content($childNode->attr('text')); 
      $childNode->replace_with($newElement)->delete(); 
     } 
    } 
    $ele->deobjectify_text();