Hello all,
The use case is quite simple. I would like to find node via an xpath statement in a string(!) that basically contains an HTML document and delete them.
I know how to find the nodes with PHP. It is basically like this: create new DOMDocument LoadHTML (or LoadXML) Create new DOMXpath and then method "query" or "evaluate". Done.
However deleting is the tricky part. One would think that you just delete the nodes with a few statements (and at the end parentNode->removechild) and just save the result back into the string with saveHTML. Unfortunately this operation transforms almost every time "too many things" in the original HTML string.
So my question now is. How could I delete the nodes return by xpath->query ($query) without using saveHTML or saveXML? And without writing my own parser.
Hope it was clear enough :-)
Thanks for looking at this!