The strip
method removes the given HTML/XML element while preserving its contents. This method is provided by the Mojo::DOM
module, which is an HTML/XML DOM parser with CSS selectors.
$dom->at('html element')->strip
This method will remove the given node while preserving its contents and return the parent element.
use 5.010;use Mojo::DOM;# Parse the htmlmy $dom = Mojo::DOM->new('<div>Inside div <p id="a">Inside paragraph </p></div>');# strip node psay $dom->at('p')->strip;
Mojo::DOM
module.$dom
scalar.p
using the strip
method while preserving the content inside it and printing the returned parent or root element.Note: The difference between the
strip
method and theremove
method is thatstrip
removes the element while preserving the content inside it, whileremove
removes everything for the given element.