Skip to content Skip to sidebar Skip to footer

How To Keep

With Xpath?

I use XPATH to remove untidy HTML tags, $nodeList = $xpath->query('//*[normalize-space(.)='' and not(self::br)]'); foreach($nodeList as $node) { $node->paren

Solution 1:

Use:

//p[not(descendant::*[self::img orself::br]) and normalize-space()='']

Solution 2:

Maybe you could use an XPath 1.0 expression like the one below to remove unwanted paragraphs:

//p[count(text())=0 and count(img)=0]

Post a Comment for "How To Keep

With Xpath?"