Reputation: 125
I want to remove all class and ID attributes from HTML by using Simple HTML Dom Parser. I'd like to remove those attributes throughout the entire HTML DOM, regardless of the type of tag. Throughout the HTML doc, there are various tags (li, p, div, etc.) that are being styled based on the CSS selector, and I basically want to remove the styling. Is there a way to traverse the entire DOM without specifying tags to remove all the Class/ID attributes?
Upvotes: 1
Views: 994
Reputation: 49208
Seems like it would be something like:
foreach ($html->find('*[id], *[class]') as $element) {
$element->id = null;
$element->class = null;
}
https://simplehtmldom.sourceforge.io/manual.htm#section_find https://simplehtmldom.sourceforge.io/manual.htm#section_access
Upvotes: 1