xmlDoc =& new DOMIT_Lite_Document(); $xmlDoc =& $this->xmlDoc; $xmlDoc->resolveErrors(true); $result = $xmlDoc->loadXML( $file, false, false); if (!$result) return false; $root =& $xmlDoc->documentElement; if ($root->getTagName() !== 'html') { return false; } $head =& $root->getElementsByPath('head', 1); $body =& $root->getElementsByPath('body', 1); if (empty($head)) return false; if (empty($body)) return false; if (!is_object($head)) { return false; } if (!is_object($body)) { return false; } $title =& $head->getElementsByPath('title', 1); if (empty($title)) return false; if (!is_object($title)) return false; $this->title = $title->getText(); unset($title); $metas =& $head->getElementsByPath('meta'); if (is_object($metas) && ($length = $metas->getLength()) > 0) { for ($i=0; $i<$length; $i++) { $meta =& $metas->item($i); $this->metas[] = $meta->toString(); unset($meta); } } unset($metas); $links =& $head->getElementsByPath('link'); if (is_object($links) && ($length = $links->getLength()) > 0) { for ($i=0; $i<$length; $i++) { $link =& $links->item($i); $this->links[] = $link->toString(); unset($link); } } unset($links); $styles =& $head->getElementsByPath('style'); if (is_object($styles) && ($length = $styles->getLength()) > 0) { for ($i=0; $i<$length; $i++) { $style =& $styles->item($i); $this->styles[] = preg_replace('%\s*/>$%', '>', $style->toString()); unset($style); } } unset($styles); $scripts =& $head->getElementsByPath('script'); if (is_object($scripts) && ($length = $scripts->getLength()) > 0) { for ($i=0; $i<$length; $i++) { $script =& $scripts->item($i); $this->scripts[] = preg_replace('%\s*/>$%', '>', $script->toString()); unset($script); } } unset($scripts); unset($head); $this->body = ''; foreach ($body->childNodes as $node) { $this->body .= $node->toString(); } unset($body); return true; } }