Possible Duplicate:
How to insert HTML to PHP DOMNode?
Continuing off of this question, here's the code I'm about to start using:
function getHTMLDOMSegment( $file )
{
$doc = new DOMDocument();
$doc->loadHTMLFile( $file );
$body = $dom->getElementsByTagName('body')->item(0);
return $body->childNodes;
}
Then I'd simply iterate over the children, using importNode and append each wherever they need to go in another HTML-loaded DOMDocument.
Does this sound right?
Edit: To be clear, since the source files I'm working with may not be "proper" XHTML, I need to go through loadHTMLFile like this no matter what, apparently.
Also, because this might be having to work with a large amount of HTML content, my goal is to be efficient as well.