Hi Guys,
We have a requirement to download the internal table data as XML file.
I am generating a XML file (welcome.xml) through PHP. The PHP code is as -
Code:
<?php
$xmlString = '<?xml version="1.0" encoding="UTF-8"?>
<urlset
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:image="http://www.google.com/schemas/sitemap-image/1.1"
xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd"
xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>http://www.codexworld.com</loc>
<lastmod>2016-07-04T07:46:18+00:00</lastmod>
<changefreq>always</changefreq>
<priority>1.00</priority>
</url>
</urlset>';
$dom = new DOMDocument;
$dom->preserveWhiteSpace = FALSE;
$dom->loadXML($xmlString);
$dom->formatOutput = TRUE;
//Save XML as a file
$dom->save('test/welcome.xml');
//View XML document
echo $dom->saveXml();
?>
Able to download the XML file in correct format, but when opened in NOTEPAD we are getting the complete tags of the XML in a single line.
We need the notepad file also to look like the format of the XML file when opened.
Please answer is there any solution for this (XML file should be in XML format when opened in Notepad). It should be done without using any XML Editor (XML formatting tool).
I tell you for your information that we are using Linux server and the code is lying inside Linux server. Also we don't want to use any XML Editor (XML formatting tool).
Please reply as soon as possible.
Thanks in advance.
Harish Pathak