Page 1 of 1

Getting content from external website by a div id

Posted: Fri Jan 21, 2011 1:23 am
by sateesh
Hi

I am developing a website on social engine. I have created a menu item for News and need to get the content for that menu item from an external website by a div id.

Here the problem is I am getting the content between the particular div id and as well as particular div class.
<div class="clearfix" id="ja-zinfp"> this is the source div.

<div class="something"> working good
<div id="something"> working good
<div class="clearfix" id="ja-zinfp"> not working

This is the line of code what I have wriiten for this task
preg_match_all ("/<div class=\"ja-content-top clearfix\">([^`]*?)<\/div>/", $data, $matches);
print_r($matches[1]);

Can anybody help me in this issue

Thanks
Sateeesh.

Re: Getting content from external website by a div id

Posted: Fri Jan 21, 2011 3:01 am
by josh

Re: Getting content from external website by a div id

Posted: Fri Jan 21, 2011 4:21 am
by sateesh
Actually I need to get the content from this div

preg_match_all ("/<div class=\"clearfix\" id=\"ja-zinfp\">([^`]*?)<\/div>/", $data, $matches);

Can I place the div as above

Thanks
Sateesh

Re: Getting content from external website by a div id

Posted: Fri Jan 21, 2011 12:19 pm
by John Cartwright
XPath is basically a HTML query language.

Using Zend_Dom_Query, you could do something like

Code: Select all

$dom = new Zend_Dom_Query($html);
$results = $dom->query('#ja-zinfp');
Which will return a DOMElement for you to do with as you please :D

Re: Getting content from external website by a div id

Posted: Fri Jan 21, 2011 2:21 pm
by pickle
This belongs in PHP-Code. Please make an attempt to post questions in the appropriate forum.