Monday 15 June 2015

parsing - How to parse form elements from html response -



parsing - How to parse form elements from html response -

<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="head1"><title> online-edu-help.com </title></head> <body> <form name="form1" method="post" action="post.aspx" id="form1"> <input type="hidden" name="__viewstate" id="__viewstate" value="/wepdwukmtyxntmxotk3mgrktkizyxxt1usqvfzywkcnecsqxls=" /> <span id="lblerror"></span> <span id="lblnoerror">accepted: 3231401</span> <br /> </form> </body> </html>

i want parse value of lblerror , lblnoerror above html response in php.

<?php $html = '<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="head1"><title> online-edu-help.com </title></head> <body> <form name="form1" method="post" action="post.aspx" id="form1"> <input type="hidden" name="__viewstate" id="__viewstate" value="/wepdwukmtyxntmxotk3mgrktkizyxxt1usqvfzywkcnecsqxls=" /> <span id="lblerror"></span> <span id="lblnoerror">accepted: 3231401</span> <br /> </form> </body> </html>'; $dom = new domdocument(); $dom->loadhtml($html); $lblnoerror = $dom->getelementbyid('lblnoerror'); echo $lblnoerrorvalue = $lblnoerror->nodevalue; $lblerror = $dom->getelementbyid('lblerror'); echo $lblerrorvalue = $lblerror->nodevalue; ?>

parsing domdocument simpledom

No comments:

Post a Comment