Add new attribute in PHP
Description
The following code shows how to add new attribute.
Example
//w ww. j ava2 s . c o m
<?php
$doc = new DOMDocument("1.0");
$node = $doc->createElement("para");
$newnode = $doc->appendChild($node);
$newnode->setAttribute("align", "left");
echo $doc->saveXML();
?>
The code above generates the following result.