Re: Extract HTML tags

From: Date: Thu, 10 Oct 2002 02:47:39 +0000
Subject: Re: Extract HTML tags
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-119489@lists.php.net to get a copy of this message
If you can guarantee that your body tags are lowercase and have no args, then I would check out strtok() in the string functions. If your body tags are not that easy to match then I suggest you use either a regex or write a state machine to parse the string. A good html parsing state machine is in the php source for htmlstriptags. Note that Regex's are extremely expensive on large strings. Cheers, Owen Prime http://www.noggin.com.au Shawn McKenzie wrote: > I've loaded an html file into a string. What I'd like to do is create two > new strings: > > first new string with the original string but remove all content from the > beginning of the file up to and including <body>, and then remove from the > end of file up to and including </body> > > second new string only containing content after <head> up to and including > <body> > > Any ideas on simple ways to do this? > > TIA > -Shawn

« previous php.general (#119489) next »