Create a new SimpleXMLElement object, then output the content of the body node:
The __construct() function creates a new SimpleXMLElement object.
| Parameter | Description |
|---|---|
| data | Required. Specifies A well-formed XML string or the path or URL to an XML document if data_is_url is TRUE |
| options | Optional. Specifies additional Libxml parameters. Is set by
specifying the option and 1 or 0 (TRUE or FALSE, e.g. LIBXML_NOBLANKS(1)) Possible values:
|
| data_is_url | Optional. TRUE specifies that data is a path/URL to an XML document instead of string data. Default is FALSE |
| ns | Optional. Specifies a namespace prefix or URI |
| is_prefix | Optional. Specifies a Boolean value. TRUE if ns is a prefix. FALSE if ns is a URI. Default is FALSE |
| Return Value: | Returns a SimpleXMLElement object that represents data |
|---|---|
| PHP Version: | 5.0.1+ |
| PHP Changelog: | PHP 5.1.2: options and data_is_url parameters added. PHP 5.2: ns and is_prefix parameters added. |
Assume we have the following XML file, "note.xml":
Create a SimpleXMLElement object from a URL:
PHP SimpleXML Reference
The perfect solution for professionals who need to balance work, family, and career building.
More than 10 000 certificates already issued!
The HTML Certificate documents your knowledge of HTML.
The HTML5 Certificate documents your knowledge of advanced HTML5.
The CSS Certificate documents your knowledge of advanced CSS.
The JavaScript Certificate documents your knowledge of JavaScript and HTML DOM.
The jQuery Certificate documents your knowledge of jQuery.
The XML Certificate documents your knowledge of XML, XML DOM and XSLT.
The ASP Certificate documents your knowledge of ASP, SQL, and ADO.
The PHP Certificate documents your knowledge of PHP and SQL (MySQL).
Your message has been sent to W3Schools.