Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php /* parse_html.php */
- /**
- * Parse (possibly) badly formed HTML
- *
- * SimpleXML: http://php.net/simplexml
- * DomDocument: http://php.net/manual/en/class.domdocument.php
- */
- $html = file_get_contents('http://somesite.com/');
- // create a new DOMDocument and set strictErrorChecking to FALSE
- $dom = new DOMDocument();
- $dom->strictErrorChecking = FALSE;
- // load the (probably dodgy) HTML into the DOMDocument
- $dom->loadHTML($html);
- // load the DOMDocument into SimpleXML
- $obj = simplexml_import_dom($dom);
- // examine it
- echo '<xmp>'. print_r($obj, 1). '</xmp>';
- ?>
Advertisement
Add Comment
Please, Sign In to add comment