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();
    }