ndwHombre
asked on
How do I put the contents of a web page into an xml parser?
I want to put the contents of a web page into an xml parser so that it will be easier to grab just the info I need. Is there a way to do this? The code I'm using to grab a web page is below.
<?php
$url = "http://www.baseball-reference.com/leagues/MLB/2009-standard-batting.shtml";
$str = file_get_contents($url);
function get_url_contents($url){
$crl = curl_init();
$timeout = 15;
curl_setopt ($crl, CURLOPT_URL,$url);
curl_setopt ($crl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($crl, CURLOPT_CONNECTTIMEOUT, $timeout);
$ret = curl_exec($crl);
curl_close($crl);
return $ret;
}
?>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.