using System;
using System.Collections.Generic;
using System.Globalization;
using System.Text;
using System.Xml;
namespace Nikse.SubtitleEdit.Core.SubtitleFormats
{
public class UnknownSubtitle13 : SubtitleFormat
{
public override string Extension => ".xml";
public override string Name => "Unknown 13";
public override string ToText(Subtitle subtitle, string title)
{
string xmlStructure =
"" + Environment.NewLine +
"";
var xml = new XmlDocument();
xml.LoadXml(xmlStructure);
int id = 1;
foreach (Paragraph p in subtitle.Paragraphs)
{
XmlNode paragraph = xml.CreateElement("entry");
XmlAttribute duration = xml.CreateAttribute("timeOut");
duration.InnerText = p.EndTime.ToString();
paragraph.Attributes.Append(duration);
XmlAttribute start = xml.CreateAttribute("timeIn");
start.InnerText = p.StartTime.ToString();
paragraph.Attributes.Append(start);
XmlAttribute idAttr = xml.CreateAttribute("id");
idAttr.InnerText = id.ToString(CultureInfo.InvariantCulture);
paragraph.Attributes.Append(idAttr);
paragraph.InnerText = " lines, string fileName)
{
_errorCount = 0;
var sb = new StringBuilder();
lines.ForEach(line => sb.AppendLine(line));
string allText = sb.ToString();
if (!allText.Contains("") || !allText.Contains("timeIn="))
return;
var xml = new XmlDocument { XmlResolver = null };
try
{
xml.LoadXml(allText);
}
catch (Exception exception)
{
System.Diagnostics.Debug.WriteLine(exception.Message);
_errorCount = 1;
return;
}
foreach (XmlNode node in xml.DocumentElement.SelectNodes("entry"))
{
try
{
string start = node.Attributes["timeIn"].InnerText;
string end = node.Attributes["timeOut"].InnerText;
string text = node.InnerText;
if (text.StartsWith("![CDATA[", StringComparison.Ordinal))
text = text.Remove(0, 8);
if (text.StartsWith("