2

Possible Duplicate:
innerHTML in PHP’s DomDocument?

I'm writing an application to fetch preview content from rss feeds. For that I want to get the HTML content of a specific div.

The text I am fetching looks like this

<P>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean egestas enim non tellus interdum mollis. Pellentesque accumsan, purus quis facilisis vulputate,</P>
<P>leo enim rhoncus velit, non consectetur lacus libero a eros. Fusce rutrum, sapien eget facilisis placerat, metus enim sagittis ante, quis elementum velit tortor sit amet purus. </P>
<P>Mauris accumsan, dolor quis mollis iaculis, metus nisl lacinia neque, vel condimentum erat nisl ut lorem. Cras vestibulum urna in nisl ullamcorper rhoncus tincidunt massa </P>
<P>pretium. Nunc dui est, imperdiet et vulputate sit amet, facilisis semper ante. Duis ac ornare elit. Morbi gravida dolor vitae nunc tempus a hendrerit odio posuere. Morbi </p>

But when I have curld the page and parse it en get the nodeValue I get text without the Paragraph tags

$dom = new DOMDocument();
$dom->validateOnParse = false;
$html = get_data($item['link']);
$dom->loadHTML($html);
$storycontents = $dom->getElementById('story-body-text');
echo '<TR><TD>'.$storycontents ->nodeValue.' </TD></TR>';

Is there a way in DOMDocument to get the "innerHTML" property of a specific id?

Community
  • 1
  • 1
Tschallacka
  • 27,901
  • 14
  • 88
  • 133

1 Answers1

4

Thanks to @simone How to get innerHTML of DOMNode?

$tmp_dom = new DOMDocument(); 
$tmp_dom->appendChild($tmp_dom->importNode($child, true)); 
$innerHTML.=trim($tmp_dom->saveHTML()); 

Didn't show up in my search, but thank you none the less.

Community
  • 1
  • 1
Tschallacka
  • 27,901
  • 14
  • 88
  • 133