Re: Re: Using DOM object, how?
| From: | Ken Tozier | Date: | Tue, 20 Sep 2005 00:05:05 +0000 |
| Subject: | Re: Re: Using DOM object, how? | ||
| References: | 1 2 3 4 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-222708@lists.php.net to get a copy of this message | ||
On Sep 19, 2005, at 7:19 PM, Stephen Leaf wrote:
On Monday 19 September 2005 06:04 pm, Ken Tozier wrote:
Not a bad Idea.
You might like this function I made then ;)
function createElement($parentNode, $name, $elements=array()) {
$node = $this->Dom->createElement($name);
for ($x=0; $x < count($elements); $x++) {
if ($elements[$x][0] == ".") {
$node->nodeValue = $elements[$x][1];
} else {
$node->setAttribute($elements[$x][0], $elements[$x][1]);
}
}
$parentNode->appendChild($node);
}
general all purpose element creator for those of us that hate to call
setAttribute a hundred times ;)
That's pretty slick. I'll have to steal it : )