php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #49666 DomElement setAttribute() invalid charater
Submitted: 2009-09-25 10:09 UTC Modified: 2009-09-25 11:14 UTC
From: ralph at bean-it dot nl Assigned:
Status: Not a bug Package: DOM XML related
PHP Version: 5.3.0 OS: Windows
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: ralph at bean-it dot nl
New email:
PHP Version: OS:

 

 [2009-09-25 10:09 UTC] 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'

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-09-25 10:43 UTC] sjoerd@php.net
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
 [2009-09-25 11:14 UTC] ralph at bean-it dot nl
Yes I have seen this, but this error was not raised before we went to php 5.3. The application and the setAttribute works fine till now. I was wandering why.

But thanks for the reply
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Nov 01 01:01:28 2024 UTC