Req #70504 [NEW]: DOMDocument::createAttribute add value as param
From: ricardo dot seromenho at gmail dot com
Operating system:
PHP version: Irrelevant
Package: DOM XML related
Bug Type: Feature/Change Request
Bug description:DOMDocument::createAttribute add value as param
Description:
------------
Now if you want to use DOMDocument::createAttribute
$domDocument = new DOMDocument('1.0', "UTF-8");
$domElement = $domDocument->createElement('field','some random data');
$domAttribute = $domDocument->createAttribute('name');
// Value for the created attribute
$domAttribute->value = 'attributevalue';
// Don't forget to append it to the element
$domElement->appendChild($domAttribute);
// Append it to the document itself
$domDocument->appendChild($domElement);
What I am suggesting is because DOMDocument::createAttribute returns
a new instance of class DOMAttr. And the DOMAttr class contructor
accepts as params the name and the value of the attribute, so I suggest
that createAttribute also accepts value as a param
$domDocument = new DOMDocument('1.0', "UTF-8");
$domElement = $domDocument->createElement('field','some random data');
// Create and set value for the attribute
$domAttribute = $domDocument->createAttribute('name',
'attributevalue');
// Don't forget to append it to the element
$domElement->appendChild($domAttribute);
// Append it to the document itself
$domDocument->appendChild($domElement);
---
Because this is possible
$domDocument = new DOMDocument('1.0', "UTF-8");
$domElement = $domDocument->createElement('field','some random data');
// Create and set value for the attribute
// Using the DOMAttr directly
$domAttribute = new \DOMAttr('name', 'attributevalue');
// Don't forget to append it to the element
$domElement->appendChild($domAttribute);
// Append it to the document itself
$domDocument->appendChild($domElement);
--
Edit bug report at https://bugs.php.net/bug.php?id=70504&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=70504&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=70504&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=70504&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=70504&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=70504&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=70504&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=70504&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=70504&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=70504&r=support
Expected behavior: https://bugs.php.net/fix.php?id=70504&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=70504&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=70504&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=70504&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=70504&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=70504&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=70504&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=70504&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=70504&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=70504&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=70504&r=mysqlcfg
Thread (3 messages)
- ricardo dot seromenho at gmail dot com