Is there no formatting for files saved by asXML (file. XML) after processing xml in SimpleXML? One line looks like Tianshu, SimpleXML, to build an xml file,
Xml-> addChild ()
Xml-> addAttribute ()
Shenma's,
When saving the disk, xml-> asXML ('File. XML'); the xml file is displayed in one row,
It's crazy to watch and watch.
He cannot wrap the line automatically. what is indentation?
Reply to discussion (solution)
It seems that there is no ..... You must manually replace it with a line break ..
Add the following sentence: $ xml-> formatOutput = true;
Add the following sentence: $ xml-> formatOutput = true;
I started to process it with SimpleXML,
$ Xml = simplexml_load_string ($ xmlstring );
AddChild
AddAttribute
Then, for the format
$ XmlDoc = new DOMDocument ('1. 0 ');
$ XmlDoc-> formatOutput = true;
$ XmlDoc-> loadXML ($ xml-> asXML ());
$ Xml_file_save = fopen ('file \ file. XML', "w"); // open the file to prepare for writing
Fwrite ($ xml_file_save, $ xmlDoc-> saveXML ());
Fclose ($ xml_file_save); // close the file
The result is the same. there is no line break or indent format in the file.
It seems that there is no ..... You must manually replace it with a line break ..
In SimpleXml, how can I add it? Can it be processed as a stored string?
Read manual tidy module
Line breaks and indentation are meaningless for XML, but in vain they increase the size of the XML document (it would be big enough)
What you see in any XML editor (including a browser) is formatted content.