PHP __construct() Function

The __construct() function creates a new SimpleXMLElement object.

final public SimpleXMLElement::__construct ( string $data [, int $options = 0 [, bool $data_is_url = FALSE [, string $ns = "" [, bool $is_prefix = FALSE ]]]] )

Example -

Example #1 Create a SimpleXMLElement object

ParameterDescription
dataA well-formed XML string or the path or URL to an XML document if data_is_url is TRUE
optionsOptionally used to specify additional Libxml parameters.
data_is_urlBy default, data_is_url is FALSE. Use TRUE to specify that data is a path or URL to an XML document instead of string data.
nsNamespace prefix or URI.
is_prefixTRUE if ns is a prefix, FALSE if it's a URI; defaults to FALSE.

Returns a SimpleXMLElement object representing data.