Build an XML file in SimpleXML,
Xml->addchild ()
Xml->addattribute ()
The Horse of God,
Save time Xml->asxml (' file.xml '); The resulting XML file is displayed on one line,
Look and want to be crazy, too disorderly pull.
Can't he just wrap it up and indent it?
Reply to discussion (solution)
It seems that there is no ... Only manual substitution plus line break is available:
Add one sentence: $xml->formatoutput = true;
Add one sentence: $xml->formatoutput = true;
I started with simplexml.
$xml = simplexml_load_string ($xmlstring);
AddChild
AddAttribute
Then in order to format this
$xmlDoc = new DOMDocument (' 1.0 ');
$xmlDoc->formatoutput = true;
$xmlDoc->loadxml ($xml->asxml ());
$xml _file_save = fopen (' File\file.xml ', "w");//Open file ready to write
Fwrite ($xml _file_save, $xmlDoc->savexml ());
Fclose ($xml _file_save);//Close file
As a result, it is still the same, and there is no wrapping and indentation formatting in the file.
It seems that there is no ... Only manual substitution plus line break is available:
In the simplexml, how to add it? Can it be treated as an existing string?
Read the manual tidy module
Wrapping, indenting is meaningless for XML, just adding the size of the XML document in vain (it's already big enough)
What you see in any XML editor (including your browser) is formatted content