Home

Simple HTML Dom is nice

Published on 2/10/2011


Recently, I had to read a web page, make some minor changes to it, and save the results. I started with DOMDocument, but couldn’t figure out how to write to a DOMNode.

Then I found Simple HTML DOM, and it’s a nice piece of software.

It’s as easy as this:

$html = file_get_html($url);

$someNode = $html->find($someXpath);
$someNode->innertext = "Hello, World!";

echo $html->save();

That’s it!

... views