PHP 8.5.0 Alpha 4 available for testing

Voting

: zero minus zero?
(Example: nine)

The Note You're Voting On

Patanjali
9 years ago
You cannot use this to update an existing attribute's value.

Instead, get a DOM version of the SimpleXMLElement and use setAttribute, as per:

$XML = '<element a="aa">Text</element>';
$snode = new simple_xml_element($XML);

$dnode = dom_import_simplexml($snode);
$dnode->setAttribute('a', 'bb');

Resulting XML for the node is:
<element a="bb">Text</element>

<< Back to user notes page

To Top