Thanks for taking interest in this
private void button3_Click(object sender, EventArgs e)
{
mxDoc = new XmlDocument();
XmlWriterSettings settings = new XmlWriterSettings();
//settings.CheckCharacters = false;
settings.Indent = true;
//Predefined declaration of xml file
XmlWriter writer = XmlWriter.Create("C:\\Index.xml", settings);
string dtdFile = @"D:\Work\eCTD\eCTDProj\eCTD\eCTD\bin\Debug\Produc t_Name\0000\util\dtd\ich-ectd-3-3-3.dtd";
StreamReader sr = File.OpenText(dtdFile);
string dtdData = sr.ReadToEnd();
sr.Close();
//MessageBox.Show(dtdData.ToString());
char[] charData = new Char[dtdData.Length];
string[] strData = new string[dtdData.Length];
strData = dtdData.Split('\n');
for (int i = 0; i < strData.Length - 1; i++)
{
string dtdLine="";
if (strData[i].Length != 0)
{
if (strData[i].Contains("?xml")) //simple declaration of xml file
{
writer.WriteStartDocument();
//writer.WriteStartDocument(false);
// Write the DocumentType node.
writer.WriteDocType("ectd:ectd", null, null, "\"util/style/ich-ectd-3-3-3.dtd\"");
// Write the Processing Instruction node.
String PItext = "type=\"text/xsl\" href=\"util/style/ectd-2-1-2.xsl\"";
writer.WriteProcessingInstruction("xml-stylesheet", PItext);
// Write a Comment node.
writer.WriteComment("sample XML");
}
MessageBox.Show(strData[i]);
if (strData[i].Contains("!ELEMENT"))
{
if (strData[i].Contains("ectd:ectd"))
{
string[] test= strData[i].Split(' ');
// Write the root element.
writer.WriteStartElement("rdf:RDF");
i++; //Next line check attribute list
if (strData[i].Contains("ATTLIST"))
{
while (!strData[i].Contains("!ELEMENT"))
{
i++;
// Write the genre attribute.
writer.WriteAttributeString("genre", "novel");
MessageBox.Show(strData[i]);
}
}
}
else if (strData[i].Contains("m1-"))
{
dtdLine = strData[i];
MessageBox.Show("m1 : "+dtdLine);
//charData = data.ToCharArray();
//charData[index] = '>';
}
else if (strData[i].Contains("m2-"))
{
MessageBox.Show("This is m2 module");
}
else if (strData[i].Contains("m3-"))
{
MessageBox.Show("This is m3 module");
}
else if (strData[i].Contains("m4-"))
{
MessageBox.Show("This is m4 module");
}
else if (strData[i].Contains("m5-"))
{
MessageBox.Show("This is m5 module");
}
else
{
MessageBox.Show("This is declaration ");
}
i++; //Next line check attribute list
if(strData[i].Contains("ATTLIST"))
{
MessageBox.Show(strData[i]);
}
}
else
{ }
}
else
{
//skip line
}
}
//charData = data.ToCharArray();
//charData[index] = '>';
//StreamWriter sw = File.CreateText(dtdFile);
//sw.Write(new String(charData));
//sw.Close();
}
code is like this only