note 12139 deleted from function.domxml-set-attribute by nlopess
| From: | nlopess@php.net | Date: | Mon, 28 Jun 2004 15:03:58 +0000 |
| Subject: | note 12139 deleted from function.domxml-set-attribute by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-72024@lists.php.net to get a copy of this message | ||
Note Submitter: ses@data.is
----
[Editor's note: Function names have been changed (by the module developer) in the latest
oncoming release (see code in ext/domxml/php_domxml.c in cvs.php.net), the function name documented
here is the one that will be supported in the next point release.
As indicated in the manual page for the domxml functions, this module is actively being modified and
thus the documentation is not finished yet.]
In my expirience the following code does NOT work:
$doc = new_xmldoc("1.0");
$root = $doc->add_root("HTML");
$head = $root->new_child("HEAD", "");
$head->new_child("TITLE", "Hier der Titel");
$head->set_attribute("Language", "ge");
The parser will return an error, relating to set_attribute being an undefined function.
After spending half an hour messing with my XML code, I came across some PHP+XML demonstration
script, which used "setattr" instead of "set_attribute", and I tried this:
$doc = new_xmldoc("1.0");
$root = $doc->add_root("HTML");
$head = $root->new_child("HEAD", "");
$head->new_child("TITLE", "Hier der Titel");
$head->setattr("Language", "ge");
And it worked! So my advice: if set_attribute isn't working, try setattr instead. And to the
maintainers of this site, IF this is some error in the documentation (for ex. set_attribute should
be setattr in every instance) please fix it, and save some poor php coder some frustration.