<p>Paragraph 1</p> <p>Paragraph 2</p><p>Paragraph 3</p>
As there is no root, how can I search the p and replace it?
I tired to use filter and replace, but it will remove all my matched elements.
$dom = FluentDOM::QueryCss('<p>Paragraph 1</p> <p>Paragraph 2</p><p>Paragraph 3</p>', 'html-fragment');
$dom->filter('p')->first()->each(function($element) {
$element->replace('hi');
});
echo $dom;
Expected:
hi <p>Paragraph 2</p><p>Paragraph 3</p>
Actual:
<p>Paragraph 2</p><p>Paragraph 3</p>
As there is no root, how can I search the
pand replace it?I tired to use
filterandreplace, but it will remove all my matched elements.Expected:
Actual: