The SimpleXMLElement addAttribute function allows you to add an attribute to an XML element. It takes two arguments - the name of the attribute and the value of the attribute.
Example:
$xml = new SimpleXMLElement('');
$xml->addAttribute('attribute1', 'value1');
$xml->addAttribute('attribute2', 'value2');
echo $xml->asXML();
This code creates a new XML element called "root" and adds two attributes to it - "attribute1" with a value of "value1" and "attribute2" with a value of "value2". It then prints out the XML string.
This function is part of the PHP SimpleXML extension, which comes pre-installed with PHP.
PHP SimpleXMLElement::addAttribute - 30 examples found. These are the top rated real world PHP examples of SimpleXMLElement::addAttribute extracted from open source projects. You can rate examples to help us improve the quality of examples.