As recommended in a previous question of mine, I am using the PHP Simple HTML DOM Parser
as a way to search an HTML document and grab contents from a specific element (in my case, a textarea). I was wondering if anyone had used this before and was able to give me any advice for my problem (or recommend another solution). The code I’m using looks like this:
include "../simple_html_dom.php";
$html = file_get_html('http://example.com');
$textarea = $html->find('textarea[id=body]');
$contents = $textarea->outertext;
echo $contents;
My problem is that the script runs the code and retrieves no data from the element (which looks like this:
<textarea id="body" name="body" rows="12" cols="75" tabindex="3">
At 2/21/10 10:15 PM, You wrote
: Hello world,
: how are you today?
</textarea>
I’m sorry to ask for advice with this certain method, but if anyone else has any advice it would be greatly appreciated. Thank you so much in advance
As you can see in the documentation
findreturns an array, so for starters you shouldnt treat it as if it were a node. Also, what you want isinnertextnotoutertext.This should work: