You could use the DOMDocument class to reformat your code:
$dom = new DOMDocument('1.0');
$dom->preserveWhiteSpace = false;
$dom->formatOutput = true;
$dom->loadXML($simpleXml->asXML());
echo $dom->saveXML();
More Related Contents:
- Format output of $SimpleXML->asXML(); [duplicate]
- Simple XML – Dealing With Colons In Nodes
- Print numeric values to two decimal places
- Parse XML with Namespace using SimpleXML [duplicate]
- PHP library for parsing XML with a colons in tag names? [duplicate]
- SimpleXML – Remove xpath node
- SimpleXML and print_r() – why is this empty?
- PHPMailer AddAddress()
- How to write CDATA using SimpleXmlElement?
- What’s the difference between PHP’s DOM and SimpleXML extensions?
- Accessing @attribute from SimpleXML
- Best way to process large XML in PHP [duplicate]
- Updating XML node with PHP
- SimpleXML how to prepend a child in a node?
- What is the best practice to use when using PHP and HTML?
- Using SimpleXML to load remote URL
- PHP – Processing Invalid XML
- PHP convert XML to JSON group when there is one child
- Using SimpleXML to create an XML object from scratch
- PHP, SimpleXML, decoding entities in CDATA
- Print Currency Number Format in PHP
- PHP SimpleXML + Get Attribute
- SimpleXML get element content based on attribute value [duplicate]
- SimpleXML SOAP response Namespace issues
- How to get attribute of node with namespace using SimpleXML? [closed]
- Hint or partially hide email address with stars (*) in PHP
- How do I format a number to a dollar amount in PHP
- How to save changed SimpleXML object back to file?
- Remove namespace from XML using PHP
- Format 32-character string with hyphens to become UUID