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.
Getting content from external website by a div id
Moderator: General Moderators
Re: Getting content from external website by a div id
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
preg_match_all ("/<div class=\"clearfix\" id=\"ja-zinfp\">([^`]*?)<\/div>/", $data, $matches);
Can I place the div as above
Thanks
Sateesh
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
Re: Getting content from external website by a div id
XPath is basically a HTML query language.
Using Zend_Dom_Query, you could do something like
Which will return a DOMElement for you to do with as you please 
Using Zend_Dom_Query, you could do something like
Code: Select all
$dom = new Zend_Dom_Query($html);
$results = $dom->query('#ja-zinfp');Re: Getting content from external website by a div id
This belongs in PHP-Code. Please make an attempt to post questions in the appropriate forum.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.