salve a tutti

ho questa situazione
la mia funzione (di un webservice) mi restituisce la seguente stringa XML

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope"><soapenv:Header/><soapenv:Body><ws:getCustomerRequestType xmlns:ws="http://www.matrix.it/cdb/ws">

Devo scrivere questo risultato in un log .txt

Come posso fare per indentare questo xml? Esiste qualche funzione che presa in iuput tale stringa la trasforma in un albero xml?

grazie