PHP __construct() Function
Complete PHP SimpleXML Reference
Definition and Usage
The __construct() function creates a new SimpleXMLElement object.
This function returns an object on success, and FALSE on failure.
Syntax
|
__construct(file,class,options,ns,is_prefix)
|
| Parameter |
Description |
| xml |
Required. Specifies the XML document or XML data to use |
| 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:
- LIBXML_COMPACT - Set small nodes allocation optimization. This may
improve the application performance
- LIBXML_DTDATTR - Set default DTD attributes
- LIBXML_DTDLOAD - Load external subset
- LIBXML_DTDVALID - Validate with the DTD
- LIBXML_NOBLANKS - Remove blank nodes
- LIBXML_NOCDATA - Set CDATA as text nodes
- LIBXML_NOEMPTYTAG - Change empty tags (e.g. <br/> to <br></br>),
only available in the DOMDocument->save() and DOMDocument->saveXML()
functions
- LIBXML_NOENT - Substitute entities
- LIBXML_NOERROR - Do not show error reports
- LIBXML_NONET - Stop network access while loading documents
- LIBXML_NOWARNING - Do not show warning reports
- LIBXML_NOXMLDECL - Drop the XML declaration when saving a document
- LIBXML_NSCLEAN - Remove excess namespace declarations
- LIBXML_XINCLUDE - Use XInclude substitution
- LIBXML_ERR_ERROR - Get recoverable errors
- LIBXML_ERR_FATAL - Get fatal errors
- LIBXML_ERR_NONE - Get no errors
- LIBXML_ERR_WARNING - Get simple warnings
- LIBXML_VERSION - Get libxml version (e.g. 20605 or 20617)
- LIBXML_DOTTED_VERSION - Get dotted libxml version (e.g. 2.6.5 or
2.6.17)
|
| is_url |
Optional. Specifies if the xml parameter is an URL. Default
is FALSE |
| ns |
Optional |
| is_prefix |
Optional |
Example
<?php
$xmlstring = <<<XML
<?xml version="1.0" encoding="ISO-8859-1"?>
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>
XML;
$xml = new SimpleXMLElement($xmlstring);
echo $xml->body[0];
?>
|
The output of the code above will be:
|
Don't forget me this weekend!
|
Complete PHP SimpleXML Reference
Make your web applications look like a million bucks
|
|
Most web applications today use boring methods to present data to their viewers using grids or simple HTML tables. FusionCharts induces "life" into the web applications by converting monotonous data into lively charts, gauges & maps.
FusionCharts works with all technologies like ASP, ASP.NET, PHP, ColdFusion, Ruby on Rails, JSP, HTML pages etc.
and connects to any database to render animated & interactive charts. It takes less than 15 minutes and no expertise
whatsoever to build your first chart and just a glance of it to captivate your audience. This fact is endorsed by our
12,000 customers and 150,000 users which include a majority of the Fortune 500 companies.
And yeah, your applications could look like a million bucks by spending just $69.
So go ahead, download your
copy of FusionCharts and start "wow-ing" your customers now!
|
 |
W3Schools' Online Certification Program
The perfect solution for professionals who need to balance work, family, and career building.
More than 4000 certificates already issued!
|
The HTML Certificate documents your knowledge of HTML, XHTML, and CSS.
The JavaScript Certificate documents your knowledge of JavaScript and HTML DOM.
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).
|