Tuesday, 12 April 2016

C# Formax XML

     // Load the XmlDocument with the XML.
     document.LoadXml(fp.FetchXml);

     writer.Formatting = System.Xml.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.
     System.IO.StreamReader sReader = new System.IO.StreamReader(mStream);

     // Extract the text from the StreamReader.
     String FormattedXML = sReader.ReadToEnd();

     string[] Result = FormattedXML.Replace("\r", "").Split(new char[] { '\n'});
     foreach (string s in Result)
        Consolw.WriteLine("{0}", s);

No comments:

Post a Comment