I am trying to copy the body portion of a HTML file for use in the current 
page. I am using PHP 5.0.1.

I think the following is close but not close enough; nothing gets imported 
by importNode. I assume this would be easy if I knew the DOM well enough; if 
someone else is then I hope this would be easy enough for them to either fix 
or provide something that works.


<?php
define("APPLICATION_ROOT", "C:/Apache2/htdocs/");
$Filename = "Categories.html";
if (!file_exists(APPLICATION_ROOT.$Filename)) {
    print "File $Filename does not exist<br>\n";
    exit;
    }
$Document = new DOMDocument();
$Document->loadHTMLFile(APPLICATION_ROOT.$Filename);
if (!$Document) {
    echo "Error loading $Filename<br>\n";
    exit;
    }
$NewDocument = new DOMDocument();
$Body = $Document->getElementsByTagName("body")->item(0);
foreach($Body->getElementsByTagName("*") as $Node)
    $NewDocument->importNode($Node, FALSE);
print $NewDocument->saveHTML();
?>

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to