HTML tutorial
CSS3 tutorial
Bootstrap tutorial
JavaScript tutorial
JQuery tutorial
AngularJS tutorial
React tutorial
NodeJS tutorial
PHP tutorial
Python tutorial
Python3 tutorial
Django tutorial
Linux tutorial
Docker tutorial
Ruby tutorial
Java tutorial
C tutorial
C ++ tutorial
Perl tutorial
JSP tutorial
Lua tutorial
Scala tutorial
Go tutorial
ASP.NET tutorial
C # tutorial
PHP SimpleXML Reference : Create a SimpleXMLElement object from a string
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+ |
PHP Changelog: | PHP 5.2.0: Added the optional ns and is_prefix parameters. PHP 5.1.2: Added the optional options and data_is_url parameters. |
Create a SimpleXMLElement object from a URL:
<?php
$xml=new SimpleXMLElement("note.xml", 0, TRUE);
echo $xml->asXML();
?>
❮ PHP SimpleXML Reference