i using simple_html_dom.php
how to get textarea value if the website has used bad tag.
the textarea tag already closed before </textarea>
like input tag.
Textarea HTML like below:
<textarea name="xxx" id="xxx" />this is value</textarea>
When i use this function, i dont get anything
$textarea = $html->find("textarea[name=xxx]");
$contents = $textarea->innertext;
echo $contents;
how to get 'this is value' using simple_html_dom.php or other alternative?
Thank you
Well, my previous comment won't work in this case, I'll leave it for info though...
Another approach is to clean it up before parsing it with simple_html_dom using
Tidy extension
. But it seems not to be working here either...A last approach I can think of, and if this is your only problematic case, is to use regex to get what you want:
<textarea.*?name="xxx".*?id="xxx".*?\/>([^<]+)<\/textarea>
==>RegEx DEMO
The output will be in group one of the resulting array
$match
. Check this working code:Working DEMO