wilbur_wc Posted August 30, 2010 Share Posted August 30, 2010 i'm trying to parse an html page and retrieve one div (or better yet one specific item from within the div). here's the div that i'm looking for... <div class="content-item "> <div class="type">XXX</div> <div class="title"><a href="xxxxxxx">THIS IS MY SEARCH FLAG</a></div> <i></i> <div class="tags"></div> <a title="View the PDF version of this article" href="this-is-the-url-i-want-to-pull.pdf" class="pdf-link"><img alt="PDF" src="xxxxx" class="xxxx">PDF</a> <a title="xxxx" href="xxx" class="xx"><img alt="xxxx" src="xxxxx" class="xxxxx">XXXXX</a> </div> you can see that my query constant (the only thing i can constantly depend on existing in the same format) is a string represented in the html as 'THIS IS MY SEARCH FLAG' and the item i ultimately want to return is a url represented by 'this-is-the-url-i-want-to-pull.pdf' i'm new to php and regex is always something of trial and error for me anyhow... any help would be greatly appreciated. thanks Quote Link to comment Share on other sites More sharing options...
wilbur_wc Posted August 30, 2010 Author Share Posted August 30, 2010 and and one note... the number of divs/tags within the main div is not constant. Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted August 30, 2010 Share Posted August 30, 2010 Here is a HTML DOM class that makes finding specific data on a page easy - http://sourceforge.net/projects/simplehtmldom/ Quote Link to comment Share on other sites More sharing options...
wilbur_wc Posted August 31, 2010 Author Share Posted August 31, 2010 thanks PFMaBiSmAd... that does the job, and then some... great class and i'm already up and running with it. however, i'm still curious if there's a regex solution. thanks 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.