Improve error handling

This commit is contained in:
niksedk 2021-12-11 14:55:42 +01:00
parent e864dbbe18
commit 7432536495

View File

@ -1355,6 +1355,16 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
var nsmgr = new XmlNamespaceManager(xml.NameTable); var nsmgr = new XmlNamespaceManager(xml.NameTable);
nsmgr.AddNamespace("ttml", "http://www.w3.org/ns/ttml"); nsmgr.AddNamespace("ttml", "http://www.w3.org/ns/ttml");
XmlNode head = xml.DocumentElement.SelectSingleNode("ttml:head", nsmgr); XmlNode head = xml.DocumentElement.SelectSingleNode("ttml:head", nsmgr);
if (head == null)
{
head = xml.DocumentElement.SelectSingleNode("head", nsmgr);
}
if (head == null)
{
return list;
}
foreach (XmlNode node in head.SelectNodes("//ttml:style", nsmgr)) foreach (XmlNode node in head.SelectNodes("//ttml:style", nsmgr))
{ {
if (node.Attributes["xml:id"] != null) if (node.Attributes["xml:id"] != null)
@ -1369,7 +1379,9 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
} }
catch catch
{ {
// Ignore
} }
return list; return list;
} }