Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in /data/e/7/e76990b9-3372-4d88-8089-fce36e16744a/webperfection.net/sub/rady-nosu/wp-content/plugins/seo-ultimate/modules/class.su-module.php on line 1195
php domdocument extract text nodes with original html

February 23, 2014 | In: Programovanie

php domdocument extract text nodes with original html

Extracting html from domdocument without parsing original node

preserveWhiteSpace = false;
$dom->loadHTML($body);
// $html = $dom->saveHTML();
// var_dump($html);

// create xpath
$xpath = new DOMXPath($dom);
// read everything from body 
$query = '/html/body/* | /html/body/text()';
$entries = $xpath->query($query);
foreach ($entries as $entry) {
var_dump(
// parsed value
    $entry->nodeValue,
// node name (b/div/..)
    $entry->nodeName,
// f.e. comment...
    $entry->nodeType,
// get me the original node (text

		
		
		
		

Comments are closed.