How to use asXML in PHP

In this article I will explain how asXML function used in PHP.
  • 1565

asXML() Function

This function gives us to the XML document as a string. If this function failure it returns FALSE.


class SimpleXMLElement
string asXML(file)


 Parameter  Description
 file  It is optional, It writes the XML to a file instead of returning it.


XML Code

<?xml version="1.0" encoding="ISO-8859-1"?>
<to>Tanya says</to>
<from> to Sachin</from>
<body>Don't forget me this weekend!</body>

PHP Code

if (file_exists('D:\sachin\parse.xml'))
$xml = simplexml_load_file('D:\sachin\parse.xml');

echo $xml->asXML();



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


More Articles

© 2020 DotNetHeaven. All rights reserved.