Hi I have used Curl to obtain a webpage (stored in a variable called $result). Within this webpage I just want to obtain specific content that is within a certain DIV tag. Here is the part of the page that contains the DIV tag that I am interested in:

    <div id="bookInfo">
<table>
<tr>
<td><b>Title:</b>  </td>
<td>OLIVER TWIST</td>
</tr>
<tr>
<td><b>Author:</b>  </td>
<td>CHARLES DICKENS</td>
</tr>
<tr>
<td><b>Publisher:<b/>  </td>
<td>PUFFIN</td>
</tr>
<tr>
<td><b>Published Date:</b></td>
<td>27-MAR-2002</td>
</tr>
<tr>
<td><b>PRICE:</b>  </td>
<td>8.99</td>
</tr>
</table>
</div>

What I want to do is store the title, author, date etc into a variable. For example I want a $title variable that holds 'OLIVER TWIST', an $author variable that holds 'CHARLES DICKENS' and so on. Also for the date published, I just want the last 4 digits, i.e the year.

I have been looking into things like PHP DOM but I dont know how I can first obtain just this DIV tag and then just the specific content within it. Hope someone can help. Thanks

Ive been looking at DOM all day but I dont know where to start in terms of my example. Any pointers or examples would be appreciated. Thanks

Member Avatar for diafol

This has been covered to death in the php forum. Have a search here. I think about 3 or 4 members have started a similar thread just this month.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.