[ create a new paste ] login | about

Link: http://codepad.org/tqy7BGRL    [ raw code | output | fork ]

PHP, pasted on Jul 23:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<?php
    $html = '<body><p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>Not empty :)</p>
    </body>';
    
    $dom = new DomDocument();
    $dom->loadhtml($html);
    $xpath = new DomXPath($dom);
    $col = $xpath->query("//p[text()=\"\xC2\xA0\"]"); # &nbsp;
    foreach($col as $e) {
        $e->parentNode->removeChild($e);
    }
    echo $dom->saveXML($dom->getElementsByTagName('body')->item(0));


Output:
1
2
3
4
5
<body>&#13;
    &#13;
    &#13;
    <p>Not empty :)</p>&#13;
    </body>


Create a new paste based on this one


Comments: