Reputation: 25091
I am interesting in removing everything in between and including the inline style tags from my output. for example:
style="height:10px;"
The issue I have been having is, I found some php replacement expressions that work, however they are also removing my paragraph tags and such.
Any help with this is appreciated. Thank you
Upvotes: 1
Views: 2192
Reputation: 8334
This should do it using DOM and a simple XPath query to find relevant elements:
<?
$doc = new DOMDocument();
$doc->loadHTML($html);
$search = new DOMXPath($doc);
$results = $search->evaluate('//*[@style]');
foreach ($results as &$result)
$result->removeAttribute('style');
$newhtml = $doc->saveHTML();
?>
Upvotes: 2
Reputation: 6052
Use DOM Document to remove the attribute of the tags.
http://php.net/manual/en/class.domdocument.php
Upvotes: 2