0

I need to find an html input that is in an html commented section

<!-- <input type="hidden" name="ab_cde" value="12345" /> -->

the code

foreach($html->find('input') as $element) 
    {   

    }   

is not working to find it. How can it be done?

4
  • Does this help? stackoverflow.com/questions/11977896/… Commented Apr 21, 2017 at 13:32
  • I suppose it does, but I guess the commentaries can't be treated as html but as a string? Commented Apr 21, 2017 at 13:38
  • Ok, got the answer from the post, I apply that and then $doc = new DOMDocument(); $doc->loadHTML(string); . Thanks! Commented Apr 21, 2017 at 13:41
  • Yep, comments are comments, there's no reason to assume there is HTML in there. You can of course parse the comment again or look for HTML markers. Commented Apr 21, 2017 at 13:41

1 Answer 1

1

you can do via $html->find('comment') and then use an regular expression for your input in there or initialize the comments content as another html object (http://php.net/manual/en/domdocument.loadhtml.php) to be searched like you tried before.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.