views:

65

answers:

1

I'm using readability's code to extract HTML from a web page. How do I display it on a page?

$content = grabArticle($webpage);
echo $content;

ERROR => Object of class DOMElement could not be converted to string...
A: 
$content = grabArticle($webpage);

$newdoc = new DOM;
$newdoc->importNode($content);

$html = $newdoc->saveHTML();

That'll creat a new complete HTML document based on the node you extracted in grabArticle. If you're inserting that into another HTML page, you'll need to strip off the leading/trailing tags that DOM inserts.

Marc B