Minor refact: new XmlDocument { XmlResolver = null }

This commit is contained in:
Waldi Ravens 2015-08-27 03:18:25 +02:00
parent 2a7366c642
commit 79c842317b
34 changed files with 62 additions and 103 deletions

View File

@ -76,8 +76,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
xmlAsText = xmlAsText.Replace("< /", "</");
var xml = new XmlDocument();
xml.XmlResolver = null;
var xml = new XmlDocument { XmlResolver = null };
try
{
xml.LoadXml(xmlAsText);
@ -109,4 +108,4 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
}
}
}
}

View File

@ -45,8 +45,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
string xmlAsString = sb.ToString().Trim();
if (xmlAsString.Contains("<DCSubtitle"))
{
var xml = new XmlDocument();
xml.XmlResolver = null;
var xml = new XmlDocument { XmlResolver = null };
try
{
xml.LoadXml(xmlAsString);
@ -462,8 +461,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
var sb = new StringBuilder();
lines.ForEach(line => sb.AppendLine(line));
var xml = new XmlDocument();
xml.XmlResolver = null;
var xml = new XmlDocument { XmlResolver = null };
xml.LoadXml(sb.ToString().Trim());
var ss = Configuration.Settings.SubtitleSettings;
@ -734,4 +732,4 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
}
}
}
}

View File

@ -487,8 +487,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
var sb = new StringBuilder();
lines.ForEach(line => sb.AppendLine(line));
var xml = new XmlDocument();
xml.XmlResolver = null;
var xml = new XmlDocument { XmlResolver = null };
xml.LoadXml(sb.ToString().Replace("<dcst:", "<").Replace("</dcst:", "</").Replace("xmlns=\"http://www.smpte-ra.org/schemas/428-7/2007/DCST\"", string.Empty)); // tags might be prefixed with namespace (or not)... so we just remove them
var ss = Configuration.Settings.SubtitleSettings;

View File

@ -60,8 +60,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
if (xmlAsString.Contains("<dcst:SubtitleReel") || xmlAsString.Contains("<SubtitleReel"))
{
var xml = new XmlDocument();
xml.XmlResolver = null;
var xml = new XmlDocument { XmlResolver = null };
try
{
xmlAsString = xmlAsString.Replace("<dcst:", "<").Replace("</dcst:", "</");
@ -488,8 +487,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
var sb = new StringBuilder();
lines.ForEach(line => sb.AppendLine(line));
var xml = new XmlDocument();
xml.XmlResolver = null;
var xml = new XmlDocument { XmlResolver = null };
xml.LoadXml(sb.ToString().Replace("<dcst:", "<").Replace("</dcst:", "</").Replace("xmlns=\"http://www.smpte-ra.org/schemas/428-7/2010/DCST\"", string.Empty)); // tags might be prefixed with namespace (or not)... so we just remove them
var ss = Configuration.Settings.SubtitleSettings;

View File

@ -70,8 +70,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
if (!allText.Contains("<EEG708Captions") || !allText.Contains("<Caption"))
return;
var xml = new XmlDocument();
xml.XmlResolver = null;
var xml = new XmlDocument { XmlResolver = null };
try
{
xml.LoadXml(allText);

View File

@ -59,8 +59,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
if (!xml.Contains("<transcript") || !xml.Contains("<content"))
return;
var doc = new XmlDocument();
doc.XmlResolver = null;
var doc = new XmlDocument { XmlResolver = null };
doc.LoadXml(xml);
var content = doc.DocumentElement.SelectSingleNode("content");
if (content == null)
@ -73,4 +72,4 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
LoadF4TextSubtitle(subtitle, text);
}
}
}
}

View File

@ -102,8 +102,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
if (!allText.Contains("<FLVCoreCuePoints") && allText.Contains("<CuePoint"))
return;
var xml = new XmlDocument();
xml.XmlResolver = null;
var xml = new XmlDocument { XmlResolver = null };
try
{
xml.LoadXml(allText);
@ -154,4 +153,4 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
}
}
}
}

View File

@ -29,8 +29,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
string xmlAsString = sb.ToString().Trim();
if (xmlAsString.Contains("</filmeditxml>") && xmlAsString.Contains("</subtitle>"))
{
var xml = new XmlDocument();
xml.XmlResolver = null;
var xml = new XmlDocument { XmlResolver = null };
try
{
xml.LoadXml(xmlAsString);
@ -127,8 +126,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
_errorCount = 0;
var sb = new StringBuilder();
lines.ForEach(line => sb.AppendLine(line));
var xml = new XmlDocument();
xml.XmlResolver = null;
var xml = new XmlDocument { XmlResolver = null };
xml.LoadXml(sb.ToString().Trim());
string lastKey = string.Empty;
foreach (XmlNode node in xml.DocumentElement.SelectNodes("subtitle"))
@ -174,4 +172,4 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
}
}
}
}

View File

@ -43,8 +43,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
var sb = new StringBuilder();
lines.ForEach(line => sb.AppendLine(line));
var xml = new XmlDocument();
xml.XmlResolver = null;
var xml = new XmlDocument { XmlResolver = null };
try
{
xml.LoadXml(sb.ToString().Trim());

View File

@ -156,14 +156,12 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
var sb = new StringBuilder();
lines.ForEach(line => sb.AppendLine(line));
var xml = new XmlDocument();
xml.XmlResolver = null;
var xml = new XmlDocument { XmlResolver = null };
try
{
xml.LoadXml(sb.ToString().Trim());
var header = new XmlDocument();
header.XmlResolver = null;
var header = new XmlDocument { XmlResolver = null };
header.LoadXml(sb.ToString());
if (header.SelectSingleNode("sequence/media/video/track") != null)
header.RemoveChild(header.SelectSingleNode("sequence/media/video/track"));
@ -293,4 +291,4 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
}
}
}
}

View File

@ -226,14 +226,12 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
var sb = new StringBuilder();
lines.ForEach(line => sb.AppendLine(line));
var xml = new XmlDocument();
xml.XmlResolver = null;
var xml = new XmlDocument { XmlResolver = null };
try
{
xml.LoadXml(sb.ToString().Trim());
var header = new XmlDocument();
header.XmlResolver = null;
var header = new XmlDocument { XmlResolver = null };
header.LoadXml(sb.ToString());
if (header.SelectSingleNode("sequence/media/video/track") != null)
header.RemoveChild(header.SelectSingleNode("sequence/media/video/track"));
@ -363,4 +361,4 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
}
}
}
}

View File

@ -103,8 +103,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
var sb = new StringBuilder();
lines.ForEach(line => sb.AppendLine(line));
var xml = new XmlDocument();
xml.XmlResolver = null;
var xml = new XmlDocument { XmlResolver = null };
xml.PreserveWhitespace = true;
try
{

View File

@ -127,8 +127,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
var sb = new StringBuilder();
lines.ForEach(line => sb.AppendLine(line));
var xml = new XmlDocument();
xml.XmlResolver = null;
var xml = new XmlDocument { XmlResolver = null };
try
{
xml.LoadXml(sb.ToString().Trim());

View File

@ -442,13 +442,11 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
var sb = new StringBuilder();
lines.ForEach(line => sb.AppendLine(line));
var xml = new XmlDocument();
xml.XmlResolver = null;
var xml = new XmlDocument { XmlResolver = null };
try
{
xml.LoadXml(sb.ToString().Trim());
var header = new XmlDocument();
header.XmlResolver = null;
var header = new XmlDocument { XmlResolver = null };
header.LoadXml(sb.ToString());
if (header.SelectSingleNode("sequence/media/video/track") != null)
header.RemoveChild(header.SelectSingleNode("sequence/media/video/track"));
@ -614,4 +612,4 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
}
}
}
}

View File

@ -116,8 +116,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
if (!x.Contains("<fcpxml version=\"1.4\">") && !x.Contains("<fcpxml version=\"1.5\">"))
return;
var xml = new XmlDocument();
xml.XmlResolver = null;
var xml = new XmlDocument { XmlResolver = null };
try
{
xml.LoadXml(x.Trim());
@ -194,4 +193,4 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
}
}
}
}

View File

@ -99,8 +99,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
var sb = new StringBuilder();
lines.ForEach(line => sb.AppendLine(line));
var xml = new XmlDocument();
xml.XmlResolver = null;
var xml = new XmlDocument { XmlResolver = null };
try
{
xml.LoadXml(sb.ToString().Trim());

View File

@ -88,8 +88,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
if (!sb.ToString().Contains("<TextStream"))
return;
var xml = new XmlDocument();
xml.XmlResolver = null;
var xml = new XmlDocument { XmlResolver = null };
try
{
xml.LoadXml(sb.ToString().Trim());

View File

@ -81,8 +81,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
if (string.IsNullOrEmpty(title))
title = "Subtitle Edit subtitle";
var xml = new XmlDocument();
xml.XmlResolver = null;
var xml = new XmlDocument { XmlResolver = null };
xml.LoadXml(xmlStructure);
// TODO: Set variables...
XmlNode trackNode = xml.DocumentElement.SelectSingleNode("TrackList/Track/StItemList");
@ -150,8 +149,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
return;
}
var xml = new XmlDocument();
xml.XmlResolver = null;
var xml = new XmlDocument { XmlResolver = null };
try
{
xml.LoadXml(sb.ToString().Trim());
@ -212,4 +210,4 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
}
}
}
}

View File

@ -81,8 +81,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
}
}
var xml = new XmlDocument();
xml.XmlResolver = null;
var xml = new XmlDocument { XmlResolver = null };
var nsmgr = new XmlNamespaceManager(xml.NameTable);
nsmgr.AddNamespace("ttml", "http://www.w3.org/ns/ttml");
nsmgr.AddNamespace("ttp", "http://www.w3.org/ns/10/ttml#parameter");
@ -317,4 +316,4 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
}
}
}
}

View File

@ -31,8 +31,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
{
try
{
var xml = new XmlDocument();
xml.XmlResolver = null;
var xml = new XmlDocument { XmlResolver = null };
xml.LoadXml(xmlAsString);
int numberOfParagraphs = xml.DocumentElement.SelectSingleNode("Lines").ChildNodes.Count;
return numberOfParagraphs > 0;
@ -141,8 +140,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
var sb = new StringBuilder();
lines.ForEach(line => sb.AppendLine(line));
var xml = new XmlDocument();
xml.XmlResolver = null;
var xml = new XmlDocument { XmlResolver = null };
xml.LoadXml(sb.ToString().Trim());
XmlNode div = xml.DocumentElement.SelectSingleNode("Lines");

View File

@ -224,8 +224,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
_errorCount = 0;
var sb = new StringBuilder();
lines.ForEach(line => sb.AppendLine(line));
var xml = new XmlDocument();
xml.XmlResolver = null;
var xml = new XmlDocument { XmlResolver = null };
xml.LoadXml(sb.ToString().Trim());
var nsmgr = new XmlNamespaceManager(xml.NameTable);
nsmgr.AddNamespace("w", "http://schemas.openxmlformats.org/wordprocessingml/2006/main");
@ -286,4 +285,4 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
}
}
}
}

View File

@ -47,8 +47,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
string xmlAsString = sb.ToString().Trim();
if (xmlAsString.Contains("</plist>") && xmlAsString.Contains("</dict>"))
{
XmlDocument xml = new XmlDocument();
xml.XmlResolver = null;
XmlDocument xml = new XmlDocument { XmlResolver = null };
try
{
xml.LoadXml(xmlAsString);
@ -126,8 +125,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
_errorCount = 0;
var sb = new StringBuilder();
lines.ForEach(line => sb.AppendLine(line));
XmlDocument xml = new XmlDocument();
xml.XmlResolver = null;
XmlDocument xml = new XmlDocument { XmlResolver = null };
xml.LoadXml(sb.ToString().Trim());
string lastKey = string.Empty;
foreach (XmlNode node in xml.DocumentElement.SelectNodes("array/dict"))
@ -167,4 +165,4 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
}
}
}
}

View File

@ -146,8 +146,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
if (!allText.Contains("<TitlerData") || !allText.Contains("<Data"))
return;
var xml = new XmlDocument();
xml.XmlResolver = null;
var xml = new XmlDocument { XmlResolver = null };
try
{
xml.LoadXml(allText);
@ -187,4 +186,4 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
}
}
}
}

View File

@ -279,8 +279,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
var sb = new StringBuilder();
lines.ForEach(line => sb.AppendLine(line));
var xml = new XmlDocument();
xml.XmlResolver = null;
var xml = new XmlDocument { XmlResolver = null };
xml.LoadXml(sb.ToString().Trim());
var italicStyles = new List<bool>();

View File

@ -95,8 +95,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
lines.ForEach(line => sb.AppendLine(line));
if (!sb.ToString().Contains("<Trans"))
return;
var xml = new XmlDocument();
xml.XmlResolver = null;
var xml = new XmlDocument { XmlResolver = null };
try
{
string xmlText = sb.ToString();

View File

@ -73,8 +73,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
lines.ForEach(line => sb.AppendLine(line));
if (!sb.ToString().Contains("<uts") || !sb.ToString().Contains("secOut="))
return;
var xml = new XmlDocument();
xml.XmlResolver = null;
var xml = new XmlDocument { XmlResolver = null };
try
{
string xmlText = sb.ToString();

View File

@ -114,8 +114,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
if (!xmlString.Contains("<USFSubtitles") || !xmlString.Contains("<subtitles>"))
return;
var xml = new XmlDocument();
xml.XmlResolver = null;
var xml = new XmlDocument { XmlResolver = null };
try
{
xml.LoadXml(xmlString);
@ -146,4 +145,4 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
}
}
}
}

View File

@ -90,8 +90,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
if (!allText.Contains("</Subtitle>") || !allText.Contains("<Clip "))
return;
var xml = new XmlDocument();
xml.XmlResolver = null;
var xml = new XmlDocument { XmlResolver = null };
try
{
xml.LoadXml(allText);
@ -131,4 +130,4 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
}
}
}
}

View File

@ -29,8 +29,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
string xmlAsString = sb.ToString().Trim();
if (xmlAsString.Contains("<subtitle"))
{
var xml = new XmlDocument();
xml.XmlResolver = null;
var xml = new XmlDocument { XmlResolver = null };
try
{
xml.LoadXml(xmlAsString);
@ -98,8 +97,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
var sb = new StringBuilder();
lines.ForEach(line => sb.AppendLine(line));
var xml = new XmlDocument();
xml.XmlResolver = null;
var xml = new XmlDocument { XmlResolver = null };
xml.LoadXml(sb.ToString().Trim());
foreach (XmlNode node in xml.DocumentElement.SelectNodes("subtitle"))

View File

@ -69,8 +69,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
if (!allText.Contains("<text") || !allText.Contains("start="))
return;
var xml = new XmlDocument();
xml.XmlResolver = null;
var xml = new XmlDocument { XmlResolver = null };
try
{
xml.LoadXml(allText);
@ -106,4 +105,4 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
}
}
}
}

View File

@ -101,8 +101,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
if (!xmlString.Contains("<SpeechSegment"))
return;
var xml = new XmlDocument();
xml.XmlResolver = null;
var xml = new XmlDocument { XmlResolver = null };
try
{
xml.LoadXml(xmlString);
@ -167,4 +166,4 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
}
}
}
}

View File

@ -446,4 +446,4 @@ namespace Nikse.SubtitleEdit.Forms
}
}
}
}

View File

@ -775,4 +775,4 @@ namespace Nikse.SubtitleEdit.Forms
}
}
}
}

View File

@ -251,4 +251,4 @@ namespace Nikse.SubtitleEdit.Forms
textBoxCharacters.Text = dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString();
}
}
}
}