"c sharp xml prettier" Code Answer's

You're definitely familiar with the best coding language C# that developers use to develop their projects and they get all their queries like "c sharp xml prettier" answered properly. Developers are finding an appropriate answer about c sharp xml prettier related to the C# coding language. By visiting this online portal developers get answers concerning C# codes question like c sharp xml prettier. Enter your desired code related query in the search bar and get every piece of information about C# code related question on c sharp xml prettier. 

c sharp xml prettier

By Faithful FoxFaithful Fox on Sep 02, 2020
public static string PrintXML(string xml)
{
    string result = "";

    MemoryStream mStream = new MemoryStream();
    XmlTextWriter writer = new XmlTextWriter(mStream, Encoding.Unicode);
    XmlDocument document = new XmlDocument();

    try
    {
        // Load the XmlDocument with the XML.
        document.LoadXml(xml);

        writer.Formatting = Formatting.Indented;

        // Write the XML into a formatting XmlTextWriter
        document.WriteContentTo(writer);
        writer.Flush();
        mStream.Flush();

        // Have to rewind the MemoryStream in order to read
        // its contents.
        mStream.Position = 0;

        // Read MemoryStream contents into a StreamReader.
        StreamReader sReader = new StreamReader(mStream);

        // Extract the text from the StreamReader.
        string formattedXml = sReader.ReadToEnd();

        result = formattedXml;
    }
    catch (XmlException)
    {
        // Handle the exception
    }

    mStream.Close();
    writer.Close();

    return result;
}

Source: stackoverflow.com

Add Comment

0

All those coders who are working on the C# based application and are stuck on c sharp xml prettier can get a collection of related answers to their query. Programmers need to enter their query on c sharp xml prettier related to C# code and they'll get their ambiguities clear immediately. On our webpage, there are tutorials about c sharp xml prettier for the programmers working on C# code while coding their module. Coders are also allowed to rectify already present answers of c sharp xml prettier while working on the C# language code. Developers can add up suggestions if they deem fit any other answer relating to "c sharp xml prettier". Visit this developer's friendly online web community, CodeProZone, and get your queries like c sharp xml prettier resolved professionally and stay updated to the latest C# updates. 

C# answers related to "c sharp xml prettier"

View All C# queries

C# queries related to "c sharp xml prettier"

Browse Other Code Languages

CodeProZone