Hello, good morning.
I am generating xml with php, but the code is getting everything in a single line, I need it to be indented when it is generated, respecting the hierarchy. I have no idea how to do this
Follow the code used
<?php
if(isset($_POST['create_xml'])){ echo "Programação das salas realizada";
/* All Links data from the form is now being stored in variables in string format */
$miro = $_POST['miro'];
$monet = $_POST['monet'];
$picasso = $_POST['picasso'];
$xmlBeg = "<?xml version='1.0' encoding='utf-8'?>";
$rootELementStart = "<reunioes>";
$rootElementEnd = "</reunioes>";
$xml_document= $xmlBeg;
$xml_document .= $rootELementStart;
$xml_document .= "<monet>";
$xml_document .= $monet; $xml_document .= "</monet>";
$xml_document .= "<picasso>";
$xml_document .= $picasso; $xml_document .= "</picasso>";
$xml_document .= "<miro>";
$xml_document .= $miro; $xml_document .= "</miro>";
$xml_document .= $rootElementEnd;
$path_dir .= "reunioes" .".xml";
/* Data in Variables ready to be written to an XML file */
$fp = fopen($path_dir,'w');
$write = fwrite($fp,$xml_document);
/* Loading the created XML file to check contents */
$sites = simplexml_load_file("$path_dir");
echo "<br> Checking the loaded file <br>" .$path_dir. "<br>";
?>