__construct ( $data, $options, $data_is_url, $ns, $is_prefix )

Creates a new SimpleXMLElement object.

Access

final public

Parameters

Parameter

Type

Required

Description

$data

string

Required

A well-formed XML string or the path or URL to an XML document if data_is_url is TRUE.

$options

integer

Optional

Optionally used to specify additional Libxml parameters.

$data_is_url

boolean

Optional

By 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.

$ns

string

Optional

Namespace prefix or URI.

$is_prefix

boolean

Optional

TRUE if ns is a prefix, FALSE if it’s a URI; defaults to FALSE.

Examples

Create a SimpleXMLElement object

include 'example.php';

$sxe = new SimpleXMLElement($xmlstr);
echo $sxe->movie[0]->title;
Result:
PHP: Behind the Parser

Create a SimpleXMLElement object from a URL

$sxe = new SimpleXMLElement('http://example.org/document.xml', NULL, TRUE);
echo $sxe->asXML();

Related Methods

Copyright © 2010–2013 Amazon Web Services, LLC


Feedback