Beispiel #1
0
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// This method cleans up XML to only contain valid XML characters as per the standard.
 /// </summary>
 /// <param name="xsl">The XSL.</param>
 /// <param name="migrationSourcePath">The migration source path.</param>
 /// <param name="migrationTargetPath">The migration target path.</param>
 /// ------------------------------------------------------------------------------------
 private static void CleanupXmlAndTryAgain(XslCompiledTransform xsl,
                                           string migrationSourcePath, string migrationTargetPath)
 {
     using (StreamReader reader = new StreamReader(migrationSourcePath))
         using (MemoryStream memoryStream = new MemoryStream(10))
             using (StreamWriter writer = new StreamWriter(memoryStream))
             {
                 string line;
                 while ((line = reader.ReadLine()) != null)
                 {
                     writer.WriteLine(MiscUtils.CleanupXmlString(line));
                 }
                 writer.Flush();
                 memoryStream.Seek(0, SeekOrigin.Begin);
                 using (XmlTextWriter xmlWriter = new XmlTextWriter(migrationTargetPath, Encoding.UTF8))
                     xsl.Transform(new XmlTextReader(memoryStream), xmlWriter);
             }
 }