Re: Extract specific div element from page
| From: | Myron Turner | Date: | Sat, 16 Jun 2007 00:25:20 +0000 |
| Subject: | Re: Extract specific div element from page | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-257161@lists.php.net to get a copy of this message | ||
Anthony Hiscox wrote:
Hey folks, I need to pull the contents inside of a specific div out of a page, and write it to a separate file. In this instance I am taking everything inside of <div id="content"></div> tags from a wordpress blog, this will give me only the content and not the menus, or other stuff. I need to do this because the final document will be converted for viewing on a palm pilot. Is anyone aware of a simple solution to this problem, short of parsing the entire page and starting when I hit that div opening tag, and stopping when I hit the closing tag? One problem I can see with this method is that I would have to count divs inside of that div, otherwise I would end too early on. Any advice would be greatly appreciated. Peace and Love, distatica. What is your relationship to the wordpress blog? If you have control over it, the easiest way to do this is in the browser with Javasacript. You can then send the contents to the server, using Ajax if need be, where it can be written to the file.
var content = document.getElementById("content').innerHTML;
Or if the page is being sent back to the server through a form, then put the content into a form variable and read that when the page gets back to the server, then write it to the file.
--
_____________________
Myron Turner
http://www.room535.org
http://www.bstatzero.org
http://www.mturner.org/XML_PullParser/