Extra fix for badly formattes files

This commit is contained in:
niksedk 2014-06-17 21:22:49 +02:00
parent 63f220d982
commit d51c7fc2b6

View File

@ -52,7 +52,7 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
{
try
{
xml.LoadXml(xmlAsString.Replace(" & ", " and "));
xml.LoadXml(xmlAsString.Replace(" & ", " & "));
var nsmgr = new XmlNamespaceManager(xml.NameTable);
nsmgr.AddNamespace("ttml", "http://www.w3.org/ns/ttml");
var nds = xml.DocumentElement.SelectSingleNode("ttml:body", nsmgr);
@ -393,7 +393,15 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
var sb = new StringBuilder();
lines.ForEach(line => sb.AppendLine(line));
var xml = new XmlDocument();
xml.LoadXml(sb.ToString().Trim());
try
{
xml.LoadXml(sb.ToString().Trim());
}
catch
{
xml.LoadXml(sb.ToString().Replace(" & ", " & ").Trim());
}
string ns = "http://www.w3.org/ns/ttml";
var nsmgr = new XmlNamespaceManager(xml.NameTable);