src/XmlFormatter.php
public function format($xml)
    {
        $dom = new DOMDocument('1.0');
        $dom->preserveWhiteSpace = false;
        $dom->formatOutput = true;
        $dom->loadXML($xml);
        $formatted = $dom->saveXML();

        if (!$formatted) {
            throw new Exception("An error occurred while formatting the XML");
        }

        return $formatted;
    }
public function format($xml)
    {
        $dom = new DOMDocument('1.0');
        $dom->preserveWhiteSpace = false;
        $dom->formatOutput = true;
        $dom->loadXML($xml);
        $formatted = $dom->saveXML();

        if (!$formatted) {
            throw new Exception("An error occurred while formatting the XML");
        }

        return $formatted;
    }
public function format ( $ xml ) { $ dom = new DOMDocument ( '1.0' ) ; $ dom -> preserveWhiteSpace = false ; $ dom -> formatOutput = true ; $ dom -> loadXML ( $ xml ) ; $ formatted = $ dom -> saveXML ( ) ; if ( ! $ formatted ) { throw new Exception ( "An error occurred while formatting the XML" ) ; } return $ formatted ; }
Return the XML with correct indentation.

@param string $xml
@return string
@throws Exception
Return the XML with correct indentation .