note 74936 added to function.domdocument-create-attribute

From: Date: Fri, 04 May 2007 21:29:09 +0000
Subject: note 74936 added to function.domdocument-create-attribute
Groups: php.notes 
Request: Send a blank email to php-notes+get-126208@lists.php.net to get a copy of this message
The manual (and/or DOM XML API) is inconsistent and incorrect here (or at least misleading). This article states that: "This node will not show up in the document unless it is inserted with e.g. domnode_append_child()." While the article for domnode_append_child() states that: "Note: You can not append a DOMAttribute using this method. Use DomElement->set_attribute() instead." I guess the confusing bit is that this article starts talking about "this node". What node? This article isn't about nodes, but rather attributes. And the article for domnode_append_child() indicates that domelement_set_attribute() should be used to insert a DOMAttribute, but in fact domelement_set_attribute won't accept a DOMAttribute object as input, but rather a string name and string value. This brings us right back to square one. So I have the following rhetorical questions (and answers): When you create a DOMAttribute object using this method, is the DomDocument modified directly? No, a new orphaned DOMAttribute object is simply returned. Is there a domelement_append_attribute() method (or some equivalent) that can be used to attach the DOMAttribute object to a DomElement? No, the DOMAttribute object cannot be attached to any DomElement. Note: domelement_set_attribute() can be used to add an attribute to a DOMElement. Will domelement_set_attribute() accept the DOMAttribute object as a parameter? No, is accepts the same parameters this method does (string name and string value). So what is the purpose of the returned DOMAttribute object? The returned DOMAttribute object is completely useless. So what is the purpose of this method? This method is completely useless. So now I have a non-rhetorical question: Why does the DOM XML API have methods that return useless objects? Or maybe a bigger question: why does PHP have both a DOM XML API and a DOM API, both of which operate on XML DOMs? -Robert ---- Server IP: 69.147.83.197 Probable Submitter: 70.253.78.150 ---- Manual Page -- http://www.php.net/manual/en/function.domdocument-create-attribute.php Edit -- https://master.php.net/note/edit/74936 Del: integrated -- https://master.php.net/note/delete/74936/integrated Del: useless -- https://master.php.net/note/delete/74936/useless Del: bad code -- https://master.php.net/note/delete/74936/bad+code Del: spam -- https://master.php.net/note/delete/74936/spam Del: non-english -- https://master.php.net/note/delete/74936/non-english Del: in docs -- https://master.php.net/note/delete/74936/in+docs Del: other reasons-- https://master.php.net/note/delete/74936 Reject -- https://master.php.net/note/reject/74936 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#126208) next »