469,283 Members | 2,303 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,283 developers. It's quick & easy.

Cant create xmlElement using xmlWriter in C#.net

Hello, Experts.

as i didnt got solution for "Creating XML from DTD"

So finally i started creating DTD parser in C#.net...........

Now i m facing problem while i create an xml element with name as "ectd:ectd"
using xmlwriter........

but it gives an error or exception as ':' not valide character for xml element name

please help me :)

Hiren Mistry
Jun 26 '07 #1
2 4033
Motoma
3,237 Expert 2GB
I have moved your thread to the .NET forum with the hopes that the experts there will have more information about the error you are receiving.
Jun 26 '07 #2
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
Jun 27 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

reply views Thread by Eric W | last post: by
1 post views Thread by jschell | last post: by
4 posts views Thread by FabrizioSW | last post: by
1 post views Thread by Nick | last post: by
1 post views Thread by shapper | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.