note 87361 added to function.simplexml-element-addAttribute

From: Date: Tue, 02 Dec 2008 03:36:46 +0000
Subject: note 87361 added to function.simplexml-element-addAttribute
Groups: php.notes 
Request: Send a blank email to php-notes+get-147505@lists.php.net to get a copy of this message
It took me some time to finally figure this out since nobody had blogged about it or documented it anywhere that I could find. I was trying to define a namespace and use a namespace as attributes like so: <Grantee xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="AmazonCustomerByEmail"> <EmailAddress>user@company.com</EmailAddress> </Grantee> I was using the following thinking that when they asked for the namespace, they actually meant the namespace. $simplexml->addAttribute('xsi', 'http://www.w3.org/2001/XMLSchema-instance', 'xmlns'); $simplexml->addAttribute('type', 'AmazonCustomerByEmail', 'xsi'); Instead, they want the name to have the namespace attached, and to pass the namespace URL as the third parameter. Also by doing this, the xmlns:xsi="url" gets added automatically. I had no idea. After an hour of non-stop digging, I dug through the CVS commit messages and found a clue which led me to this working code: $simplexml->addAttribute('xsi:type', 'AmazonCustomerByEmail', 'http://www.w3.org/2001/XMLSchema-instance'); ---- Server IP: 208.69.120.35 Probable Submitter: 166.129.215.23 ---- Manual Page -- http://www.php.net/manual/en/function.simplexml-element-addAttribute.php Edit -- https://master.php.net/note/edit/87361 Del: integrated -- https://master.php.net/note/delete/87361/integrated Del: useless -- https://master.php.net/note/delete/87361/useless Del: bad code -- https://master.php.net/note/delete/87361/bad+code Del: spam -- https://master.php.net/note/delete/87361/spam Del: non-english -- https://master.php.net/note/delete/87361/non-english Del: in docs -- https://master.php.net/note/delete/87361/in+docs Del: other reasons-- https://master.php.net/note/delete/87361 Reject -- https://master.php.net/note/reject/87361 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#147505) next »