How to get rid of square brackets[] after editing and saving an XML file
<p>How do I get rid of the square brackets at the end of the following XML doctype</p>

<pre><code>&lt;!DOCTYPE smil PUBLIC "-//W3C//DTD SMIL 2.0//EN" "http://www.w3.org/2001/SMIL20/SMIL20.dtd"[]&gt;
</code></pre>

<p>I have code that loads an XML file , make some changes then save the file.</p>

<p>Here is the heading of the original file(No square brackets):</p>

<pre><code>&lt;!DOCTYPE smil PUBLIC "-//W3C//DTD SMIL 2.0//EN" "http://www.w3.org/2001/SMIL20/SMIL20.dtd"&gt;
</code></pre>

<p>As you can see there is no [] at the end of <code>"SMIL20.dtd"&gt;"</code></p>

<p>when I convert the document it creates a pair of square brackets as follows "SMIL20.dtd"[]>.</p>

<p>Here is a sample:</p>

<pre><code>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 =&gt; att.Name.LocalName == "name" &amp;&amp; att.Value == "httpBase"))
                                        {
                                            gc.RemoveAttributes();
                                            gc.Add(new XAttribute("base", "rtmp://mybase"));
                                        }
                                    }
                                    else if (Configuration.Cdntosync == 1)
                                    {
                                        if(gc.Attributes().Any(att =&gt; att.Name.LocalName == "name" &amp;&amp; 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);

            }

        //}

    }
</code></pre>
