nickjonnes Posted July 31, 2011 Share Posted July 31, 2011 hey all, i as you will be able to see below i have a large amount of div's inside div's i need to get allthe information from the div class "items". i am sorry to post such a large source but i didnt want to half write out the source and waste everyones time. i have spent a large amount of time trying to figure this one out and i have been googling alot but i seem to have no luck. can anyone please help? <div class="content"> <div class="main"> <div class="hero hero-small"> <div id="slide-wrapper"> <div class="items"> <div class="container-outer"> <div class="container-inner"> <img src= "www.example.com/picture.jpg" class= "class" style="width: 300px; height: 200px;" /><a href= "www.importantsite.com/" target="_blank"> <h3>title</h3></a> <a href= "http://anotherimportantsite.com/"target="_blank"> <h4><span>blahblah</span></h4></a><p>blahblah<span>... <img src="http://example.com/blah.gif" alt="" class="example" /></span></p> </div> </div> <div class="container-outer"> <div class="container-inner"> <img src= "www.example.com/picture.jpg" class= "class" style="width: 300px; height: 200px;" /><a href= "www.importantsite.com/" target="_blank"> <h3>title</h3></a> <a href= "http://anotherimportantsite.com/"target="_blank"> <h4><span>blahblah</span></h4></a><p>blahblah<span>... <img src="http://example.com/blah.gif" alt="" class="example" /></span></p> </div> </div> <div class="container-outer"> <div class="container-inner"> <img src= "www.example.com/picture.jpg" class= "class" style="width: 300px; height: 200px;" /><a href= "www.importantsite.com/" target="_blank"> <h3>title</h3></a> <a href= "http://anotherimportantsite.com/"target="_blank"> <h4><span>blahblah</span></h4></a><p>blahblah<span>... <img src="http://example.com/blah.gif" alt="" class="example" /></span></p> </div> </div> </div> </div> </div> Quote Link to comment Share on other sites More sharing options...
joe92 Posted July 31, 2011 Share Posted July 31, 2011 You could use a positive lookahead. $pattern = "~<div class=\"items\">(.*)</div>(?=</div></div></div></div>)~" This should take the items div and everything after the items div up until an end div that is followed by at least 4 other divs, but will not return those 4 end divs. I haven't tested it though so please tell me if it works Quote Link to comment Share on other sites More sharing options...
xyph Posted August 2, 2011 Share Posted August 2, 2011 This is too complicated for RegEx to work well. Use an HTML parser, or string functions. I can show you how to do it with a parser, but you'll have to give me the entire document you want to parse. Quote Link to comment Share on other sites More sharing options...
nickjonnes Posted August 7, 2011 Author Share Posted August 7, 2011 the document i am trying to get this from is mail.com it is their news slider. if you rightclick and go to view source you will see the a huge page. i have already read through it all and worked out that this part is the only part i need that is dynamic the rest is jsut fixed code like the slide. it is only the content that changes. Quote Link to comment Share on other sites More sharing options...
nickjonnes Posted August 8, 2011 Author Share Posted August 8, 2011 hey all, i solved the issue, it took me ages and i learnt a lot as i am not a php coder but here it what i did. all form the power of google;) thanks to everyone who helped and sorry to be so confusing <?php include 'simple_html_dom.php'; // Create DOM from string $dom = file_get_html('http://www.mail.com/'); $table = $dom->getElementById('slide-wrapper'); //$ret = $html->find('div[class id=content'); echo $table; ?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.