I would like to propose adding addChild and addAtribute methods to
simplexml. I know these have been shot down in the past, but with
Marcus' recent changes to simplexml, they now make sense imo.
SimpleXMLElement::addChild(string qName, string value [,string ns])
SimpleXMLElement::addAttribute(string qName, string value [,string ns])
http://www.ctindustries.net/patches/sxe.diff.txt
Rational:
It is not possible to add elements to a tree, but new namespaced
elements/attributes cannot (although existing ones can be modified).
With these methods, new attributes and elements can be added that will
also create namespaces with prefixes in the event the do not exist in
the document.
This would pretty much eliminate the need to use DOM in most cases for
those who dont want it or have it and make behavior more consistent. It
doesn't seem right that some things can be added and other things can't.
The method names I used are abritrary so I would not be against changing
them.
Same goes The behavior of addAtribute. Right now it allows an attribute
to be added to an attribute list as long as it does not exist and
respects the namespacing passed in as parameters rather than the
namespace scope of the attribute list. For now I left it loose, but am
not against only allowing attributes to be added to elements.
To the argument that DOM could just be used to provide the
functionality, the same cause could be made for the getName,
getNamespaces and getDocNamespaces methods as well and these new
functions are much more useful imo.
Rob
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php