public static function formatXml(string $xml): string
    {
        if (empty($xml)) {
            return '';
        }

        $doc = new \DOMDocument();
        $doc->preserveWhiteSpace = false;
        $doc->formatOutput = true;
        $doc->loadXML($xml);

        return $doc->saveXML();
    }
public static function formatXml(string $xml): string
    {
        if (empty($xml)) {
            return '';
        }

        $doc = new \DOMDocument();
        $doc->preserveWhiteSpace = false;
        $doc->formatOutput = true;
        $doc->loadXML($xml);

        return $doc->saveXML();
    }
public static function formatXml ( string $ xml ) : string { if ( empty ( $ xml ) ) { return '' ; } $ doc = new \ DOMDocument ( ) ; $ doc -> preserveWhiteSpace = false ; $ doc -> formatOutput = true ; $ doc -> loadXML ( $ xml ) ; return $ doc -> saveXML ( ) ; }
Pretty print the given XML.

@param string $xml

@return string
Pretty print the given XML .