#49666 [Opn->Bgs]: DomElement setAttribute() invalid charater

From: Date: Fri, 25 Sep 2009 10:43:51 +0000
Subject: #49666 [Opn->Bgs]: DomElement setAttribute() invalid charater
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-142858@lists.php.net to get a copy of this message
ID: 49666 Updated by: sjoerd@php.net Reported By: ralph at bean-it dot nl -Status: Open +Status: Bogus Bug Type: DOM XML related Operating System: Windows PHP Version: 5.3.0 New Comment: Thank you for your report. The behavior you describe is not a bug. XML attributes can not contain spaces and can not start with a number. See the XML spec for more information: http://www.w3.org/TR/REC-xml/#attdecls Previous Comments: ------------------------------------------------------------------------ [2009-09-25 10:09:12] ralph at bean-it dot nl Description: ------------ An invalid character error is raised when I want to set an attribute on a DomElement. When I put my code in a try ... catch everything works fine Reproduce code: --------------- $doc = new DOMDocument('1.0', 'iso-8859-1'); $node = $doc->createElement('test'); $newnode = $doc->appendChild($node); $newnode->setAttribute("name application", "MyApp"); Raises an error $newnode->setAttribute("0001", "File"); Also raises an error Expected result: ---------------- The attribute is set on my DomElement Actual result: -------------- 'DOMException' with message 'Invalid Character Error' ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=49666&edit=1

« previous php.bugs (#142858) next »