How do I get rid of the square brackets at the end of the following XML doctype
<!DOCTYPE smil PUBLIC "-//W3C//DTD SMIL 2.0//EN" "http://www.w3.org/2001/SMIL20/SMIL20.dtd"[]>
I have code that loads an XML file , make some changes then save the file.
Here is the heading of the original file(No square brackets):
<!DOCTYPE smil PUBLIC "-//W3C//DTD SMIL 2.0//EN" "http://www.w3.org/2001/SMIL20/SMIL20.dtd">
As you can see there is no [] at the end of "SMIL20.dtd">"
when I convert the document it creates a pair of square brackets as follows "SMIL20.dtd"[]>.
Here is a sample:
class FileWorker
{
public static void UpdateFile(string myfile)
{
var doc = XDocument.Load(myfile);
try
{
foreach (var elem in doc.Elements())
{
if (elem.Name.LocalName == "type")
{
foreach (var child in elem.Elements())
{
if (child.Name.LocalName == "head")
{
foreach (var gc in child.Elements())
{
if (Configuration.Cdntosync == 0)
{
if (gc.Attributes().Any(att => att.Name.LocalName == "name" && att.Value == "httpBase"))
{
gc.RemoveAttributes();
gc.Add(new XAttribute("base", "rtmp://mybase"));
}
}
else if (Configuration.Cdntosync == 1)
{
if(gc.Attributes().Any(att => att.Name.LocalName == "name" && att.Value == "vod"))
{
gc.Remove();
}
gc.RemoveAttributes();
if (basecheck == false)
{
gc.Add(new XAttribute("base", "rtmp://mybase2"));
basecheck = true;
}
}
}
basecheck = false;
}
else if (child.Name.LocalName == "body")
{
foreach (var gc in child.Elements())
{
if (gc.Name.LocalName == "switch")
{
foreach (var video in gc.Elements())
{
foreach (var att in video.Attributes())
{
if (att.Name.LocalName == "src")
{
att.Value = att.Value.Replace("v1/test/", "mp4:Flvstream/");
}
}
}
}
}
}
}
}
doc.Save(myfile);
}
}
catch(Exception ex)
{
logger.Log(ExceptionLogger.LogLevel.ERROR, ex);
}
//}
}