asXML string output, writing to file , xml string to file

We have seen how we can create a SimpleXMLElement object. Now we will translate the XML data to a string by using asXML function. Here is the sample code. We have already used our XML data sample file for this.

xml-sample1.php

<?Php
require "xml-sample1.php";
$main1 = new SimpleXMLElement($str_xml);
echo $main1->asXML(); // string output
?>
To write the same string to a file we will change the above code like this.
echo $main1->asXML('test.php'); // writing to file
Above line will create the file test.php and on successful will return 1
Your Rating





Post your comments , suggestion , error , requirements etc here .




HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
©2000-2019 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer