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.

Syntax

class SimpleXMLElement
{
string asXML(file)
}

 

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

Example

XML Code

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

PHP Code

<html>
<body>
<?php
if (file_exists('D:\sachin\parse.xml'))
{
$xml = simplexml_load_file('D:\sachin\parse.xml');
}

echo $xml->asXML();
?>
</html>
</body>

Output

asxml-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.