How to use simplexml load string in PHP

In this article I will explain how simplexml_load_string function used in PHP.
  • 2179

simplexml_load_string() Function

This function loads an XML string into an object.

Syntax

simplexml_load_string(string,class,options,ns,is_prefix)

Example

<html>
<body>
<?php
$xmlstring = <<<XML
<?xml version="1.0" encoding="ISO-8859-1"?>
<note>
<to>Tanya</to>
<from>Sachin</from>
<heading>Reminder</heading>
<body>India is a nice contry</body>
</note>
XML;
$xml = simplexml_load_string($xmlstring);
var_dump($xml);
?>
</body>
</html>

 

Output


simplexml-load-string-php.jpg

You may also want to read these related articles Click here

Ask Your Question

Got a programming related question? You may want to post your question here

Programming Answers here

Categories

More Articles

© 2020 DotNetHeaven. All rights reserved.