I am trying to read in the body of a certain webpage to display on a seperate webpage, but I am having a bit of trouble with it. Right now, I use the following code
<?php
@$doc = new DOMDocument();
@$doc->loadHTMLFile('http://foo.com');
@$tags = $doc->getElementsByTagName('body');
foreach ($tags as $tag) {
$index_text .= $tag->nodeValue;
print nl2br($tag->nodeValue).'<br />';
}
?>
This code works, however it seems to remove alot of formatting, which is important to me, such as line breaks. How do I stop that from happening