PHP addChild() Function

PHP SimpleXML Reference : Add a child element to the <body> element and a new <footer> element

Definition and Usage

The addChild() function appends a child element to the SimpleXML element.

Syntax

SimpleXMLElement::addChild(name, value, ns)

Parameter Values

Parameter Description
name Required. Specifies the name of the child element to add
value Optional. Specifies the value of the child element
ns Optional. Specifies a namespace for the child element

Technical Details

Return Value: A SimpleXMLElement object that represents the child added to the XML node
PHP Version: 5.1.3+

❮ PHP SimpleXML Reference