473,322 Members | 1,778 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

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 4251
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

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

Similar topics

0
by: Eric W | last post by:
Hi, I'm working on the .NET Compact Framework, and I need a way in which i store products in an xml file. Basically, when i add a product to the system, i want to either add it to the XML file,...
1
by: jschell | last post by:
The following two cases behave differently in Net 2.0. The Case_Create_StringWriter throws an exception while the Case_XmlTextWriter does not. Is there a problem with this code? Or is this a...
2
by: Thirsty Traveler | last post by:
How would I dynamcially create an XML document of the following form: <ReceiveTSSCallBack xmlns="http://LandAm.EAI.Mainframe.TSR"> <TSSCallBack...
4
by: FabrizioSW | last post by:
Hi all i've to create a xml doc like this <?xml version="1.0" encoding="UTF-8"?> <Main xmlns:x="http://www.w3.org/1999/XML/xinclude"> <x:include href="one.xml"/> <x:include href="two.xml"/>...
1
by: Nick | last post by:
I am working on a website for a client and one of their requirements was to have a mailing list. I decided to XSLT to transform "templates" to HTML so that editing was very easy and less time...
3
by: phil | last post by:
I have written a little application that can grab part of a page from a web site. I then want to take this result and be able to serialize it so that it can be stored as XML. I am storing these...
12
by: sklett | last post by:
**Disclaimer** The element I need to create might not be valid XML, but it's not my fault, I'm following a required format for an integration project. I've got 99% of the XML created nicely...
1
by: shapper | last post by:
Hello, How do I create the following XML file at runtime? <?xml version="1.0" encoding="UTF-8"?> <gallery> <album title="Album Title" description="Album Description" lgPath="../MyAlbum/Lg/"
2
by: DragonLord | last post by:
Ok basically this is mostly working, What i want to do is create an xml file with multiple updates that have the same attribute. <root> <update> <element1>value</element1> ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.