public function formatXmlString($xmlString)
    {
        if(true === $this->isXml($xmlString))
        {
            $dom = new \DOMDocument;
            $dom->preserveWhiteSpace = false;
            $dom->loadXML($xmlString);
            $dom->formatOutput = true;

            return $dom->saveXml();
        }
        else
        {
            throw new InvalidArgumentException('Incorrect XML string');
        }
    }
public function formatXmlString($xmlString)
    {
        if(true === $this->isXml($xmlString))
        {
            $dom = new \DOMDocument;
            $dom->preserveWhiteSpace = false;
            $dom->loadXML($xmlString);
            $dom->formatOutput = true;

            return $dom->saveXml();
        }
        else
        {
            throw new InvalidArgumentException('Incorrect XML string');
        }
    }
public function formatXmlString ( $ xmlString ) { if ( true === $ this -> isXml ( $ xmlString ) ) { $ dom = new \ DOMDocument ; $ dom -> preserveWhiteSpace = false ; $ dom -> loadXML ( $ xmlString ) ; $ dom -> formatOutput = true ; return $ dom -> saveXml ( ) ; } else { throw new InvalidArgumentException ( 'Incorrect XML string' ) ; } }
Pretty print for XML

@param string $xmlString XML

@return string

@throws InvalidArgumentException
Pretty print for XML