Karthi Keyan

Karthi Keyan

  • 1k
  • 755
  • 237k

How to find the Doctype is in xml file or not.

Apr 5 2017 6:46 AM
Hi,
   I am developing a tool. that want to find the elements of xml file's and replace the contents. first i want ot find that the xml file contain DOCTYPE or not. if yes i want to change the values of that.
 
i tried this code. but got error,
 
 
var files = Directory.GetFiles(txtpath.Text);
foreach (var f in files)
{
//doc = XDocument.Load(f);
XmlDocument xmldoc = new XmlDocument();
xmldoc.LoadXml(f.Substring(f.IndexOf(Environment.NewLine))); // Error In this line.
var node = xmldoc.SelectSingleNode("//DOCTYPE");
if (node != null)
{
}
          //ele = XElement.Load(f);
}
 
how to do this. Thanks In Advance. 

Answers (2)