Hello friends, I would like to know how to replace some html tags,
replace div
tags that do not have class
or style
per tag p
I have this code:
<div>
Lorem ipsum dolor sit amet
<div>
Lorem ipsum dolor sit amet
</div>
<div>
Lorem ipsum dolor sit amet
</div>
<div>
<div class="media_embed">
<div style="xxx">
<div style="xxx">
<div style="xxx"></div>
</div>
</div>
</div>
</div>
<div>
Lorem ipsum dolor sit amet
</div>
</div>
and I would like it to be this way:
<p>
Lorem ipsum dolor sit amet
<p>
Lorem ipsum dolor sit amet
</p>
<p>
Lorem ipsum dolor sit amet
</p>
<p>
<div class="media_embed">
<div style="xxx">
<div style="xxx">
<div style="xxx"></div>
</div>
</div>
</div>
</p>
<p>
Lorem ipsum dolor sit amet
</p>
</p>
try this way but I did not get it: here is my php code
<?php
$embeds= $dom->getElementsByTagName('div');
foreach ($embeds as $embed) {
$class = $embed->getAttribute('class');
if ($class == "")
{
$link= $dom->createElement('p');
$embed->parentNode->replaceChild($link, $embed);
}
}
?>
Could you please help me?