I am trying to change all the UL tags with a Level0 class, something like this:
& lt; Ul & gt; & Lt; Li & gt; Test & lt; Ul class = "level0" & gt; ... & lt; / Ul & gt; & Lt; / Li & gt; & Lt; / Ul & gt;
will be processed
& lt; Ul & gt; & Lt; Li & gt; Test & lt; / Li & gt; & Lt; / Ul & gt;
I tried
$ _ menu = preg_replace ('/ & lt; ul class = "level0" & gt; (. *) & Lt ; \ / Ul & gt; / IU ', "", $ _menu);
But it is not working, help?
Thank you.
Yehia
I'm sure this is a duplicate, but anyway, How to do it
$ dom = new DOMDocument; // init new DOMDocument $ dom- & gt; Load HTML ($ html); // Load HTML into $ xpath = new DOMXPath ($ dom); // a new XPath $ node = $ xpath- & gt; Create query ('// ul [@ class = "level0"]'); // Find all the URLs with the class foreign ($ nodes in the form of $ nodes) {// found elements $ node-> node-> Parent node-> Remove ($ node); // Remove ul element) echo $ dom- & gt; Save HTML (); // Output Clear HTML
Comments
Post a Comment