Possible Duplicate:
read XML tag id from php
what is the way to fetch data from A Specific div id Using PHP. What i want to do is to fetch data from a div id called <div id="content"> , so all the data from that div id will be fetched in a variable.
I can fetch all content with my script but cant filter it to fetch data from a Specific div tag.
Here is the script i am using to fetch any content:
function file_get_contents_curl($url)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
$html = file_get_contents_curl("http://www.example.com");
//parsing all content:
$doc = new DOMDocument();
@$doc->loadHTML($html);
echo "$html";
any idea?
Try this but make sure you have downloaded and included PHP Simple HTML DOM Parser
Their are some ways to exclude content from div id or Tag id like,
1) Using regex
2) Using SimpleXML
3) With DOM extension Or XPath