I am using CURL to fetch form and store it in a field
..,
$str = curl_exec($ch);
The $str HTML has a textarea as follows
<td class="fntc">
Description
</td>
<td class="ffc">
<textarea name="descri" rows="6" class="emf" maxlength="128000">fictional.</textarea>
</td>
</tr>
Now I am trying to use a dom to fetch this area and was unsuccessful
$dom = new DOMDocument;
$dom->loadHTML($str);
// Get all the textarea field nodes
$inputs = $dom->getElementsByTagName('textarea');
// Iterate over the input fields and save the values we want to an array
foreach ($inputs as $input) {
$name = $input->getAttribute('name');
$val = $input->getAttribute('value');
$field_vals[$name] = $val;
}
But i am unable to get the value.Is there anything i am doing wrong here?
Since a
<textarea>contains text inside the tag, rather than in avalueattribute, you may access it withnodeValue:Update
Ok, I’ve verified this now: