HTML parse trees...

From: Date: Thu, 15 Jun 2000 01:55:02 +0000
Subject: HTML parse trees...
Groups: php.general 
Request: Send a blank email to php-general+get-1901@lists.php.net to get a copy of this message
I'm in the process of writing the same old same old stupid code, something like this: function _($tag, $attributes='', $content='') { $html = '<'.$tag; if (is_array($attributes)) { while ($attribute = each($attributes)) { if (is_int($attribute[1])) { $html .= ' '.$attribute[0].'='.$attribute[1]; } elseif (is_string($attribute[1])) { $html .= ' '.$attribute[0].'="'.$attribute[1].'"'; } elseif ($attribute[1]) { $html .= ' '.$attribute[0]; } } } else { $content = $attributes.$content; } if ($content) { return $html.'>'.$content.'</'.$tag.'>'; } else { return $html.'>'; } } Now I can't imagine that I'd be the first to do this, and I'm also seeing that this whole thing is going to end up being quite inefficient. All these string concatenations... Anyway, how come PHP doesn't have built in support for HTML (or XML) parse trees and functions to build them, store them and dump them efficiently? -- cg

« previous php.general (#1901) next »