note 44389 added to ref.dom
| From: | paulatallofusdecimalorg at rn2 dot php dot net | Date: | Wed, 04 Aug 2004 15:54:03 +0000 |
| Subject: | note 44389 added to ref.dom | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-73931@lists.php.net to get a copy of this message | ||
I'm getting fed up with having to be so verbose with DOM methods. A lot of the code I write is
of the form:
$dom = new DOMDocument();
$doc = $dom->createElement('document');
$a = $dom->createElement('title');
$b = $dom->createTextNode('title of the doc');
$a->appendChild($b);
$doc->appendChild($a);
In ActionScript, since you can 'insert' methods into classes, I have been able to create a
method like this
DOMNode.appendChildWithText(nodeName, textValue)
{
// do same as above, but encapsulated
}
which turns that mess above into a simple call like
$doc->appendChildWithText('title', 'some title');
Has anyone got any idea how I might be able to achieve the same sort of thing in PHP[5]?
----
Manual Page -- http://www.php.net/manual/en/ref.dom.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+44389
Delete -- http://master.php.net/manage/user-notes.php?action=delete+44389&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+44389&report=yes
Search -- http://master.php.net/manage/user-notes.php