Format XML string to print friendly XML string

I have an XML string as such:

<?xml version='1.0'?><response><error code="1"> Success</error></response>

There are no lines between one element and another, and thus is very difficult to read. I want a function that formats the above string:

<?xml version='1.0'?>
<response>
<error code="1"> Success</error>
</response> 

Without resorting to manually write the format function myself, is there any .Net library or code snippet that I can use offhand?

12 Answers
12

Leave a Comment