2
Reply

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

Karthi Keyan

Karthi Keyan

Apr 5 2017 6:46 AM
294
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. 

Upload Source Code  Select only zip and rar file.
Answers (2)