s or other wrappers** | If you want to also collapse empty wrappers after node removal, add an extra pass that removes empty elements (e.g. //div[not(*)]). |
| Other c12‑like classes | If the class name can be part of a longer word, modify the contains() expression accordingly. |
| Large documents | For very large HTML files, you might want to switch to a streaming parser (e.g., XMLReader) instead of DOMDocument to avoid memory exhaustion. |
| UTF‑8 handling | loadHTML() assumes ISO‑8859‑1 by default. If your document is UTF‑8, prepend a BOM or set mbinternalencoding('UTF-8') before loading. |
That’s it - drop the script into a file, replace $html with your real markup, and you’ll get a clean copy that contains no c12` classes or heading tags.
Was this helpful?
Share this article
Suggest a Correction
Found an error or have a suggestion? Let us know and we'll review it.
No comments yet. Be the first to comment!