note 106438 added to domdocument.createattribute
| From: | Beerkeeper at osu1 dot php dot net | Date: | Wed, 09 Nov 2011 15:19:48 +0000 |
| Subject: | note 106438 added to domdocument.createattribute | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-184353@lists.php.net to get a copy of this message | ||
Just in case it isn't clear (like I had), an example:
<?php
$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);
?>
Will output:
<?xml version="1.0" encoding="UTF-8"?>
<field name="attributevalue">some random data</field>
----
Server IP: 69.147.83.197
Probable Submitter: 31.160.78.110
----
Manual Page -- http://www.php.net/manual/en/domdocument.createattribute.php
Edit -- https://master.php.net/note/edit/106438
Del: integrated -- https://master.php.net/note/delete/106438/integrated
Del: useless -- https://master.php.net/note/delete/106438/useless
Del: bad code -- https://master.php.net/note/delete/106438/bad+code
Del: spam -- https://master.php.net/note/delete/106438/spam
Del: non-english -- https://master.php.net/note/delete/106438/non-english
Del: in docs -- https://master.php.net/note/delete/106438/in+docs
Del: other reasons-- https://master.php.net/note/delete/106438
Reject -- https://master.php.net/note/reject/106438
Search -- https://master.php.net/manage/user-notes.php