473,666 Members | 2,096 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Cant create xmlElement using xmlWriter in C#.net

17 New Member
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 4281
Motoma
3,237 Recognized Expert Specialist
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
Hiren Mistry
17 New Member
Thanks for taking interest in this

private void button3_Click(o bject sender, EventArgs e)
{

mxDoc = new XmlDocument();
XmlWriterSettin gs settings = new XmlWriterSettin gs();
//settings.CheckC haracters = false;
settings.Indent = true;
//Predefined declaration of xml file
XmlWriter writer = XmlWriter.Creat e("C:\\Index.xm l", settings);


string dtdFile = @"D:\Work\eCTD\ eCTDProj\eCTD\e CTD\bin\Debug\P roduct_Name\000 0\util\dtd\ich-ectd-3-3-3.dtd";

StreamReader sr = File.OpenText(d tdFile);
string dtdData = sr.ReadToEnd();
sr.Close();
//MessageBox.Show (dtdData.ToStri ng());

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.WriteSta rtDocument();

//writer.WriteSta rtDocument(fals e);
// Write the DocumentType node.
writer.WriteDoc Type("ectd:ectd ", null, null, "\"util/style/ich-ectd-3-3-3.dtd\"");

// Write the Processing Instruction node.
String PItext = "type=\"tex t/xsl\" href=\"util/style/ectd-2-1-2.xsl\"";
writer.WritePro cessingInstruct ion("xml-stylesheet", PItext);

// Write a Comment node.
writer.WriteCom ment("sample XML");


}
MessageBox.Show (strData[i]);
if (strData[i].Contains("!ELE MENT"))
{

if (strData[i].Contains("ectd :ectd"))
{
string[] test= strData[i].Split(' ');
// Write the root element.


writer.WriteSta rtElement("rdf: RDF");








i++; //Next line check attribute list
if (strData[i].Contains("ATTL IST"))
{
while (!strData[i].Contains("!ELE MENT"))
{
i++;
// Write the genre attribute.
writer.WriteAtt ributeString("g enre", "novel");
MessageBox.Show (strData[i]);
}
}
}
else if (strData[i].Contains("m1-"))
{
dtdLine = strData[i];
MessageBox.Show ("m1 : "+dtdLine);

//charData = data.ToCharArra y();
//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("ATTL IST"))
{
MessageBox.Show (strData[i]);
}
}
else
{ }
}
else
{
//skip line
}
}

//charData = data.ToCharArra y();
//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
1005
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, (if it exists), or create a new XML file with the item in it if the file doesn't exist. Bearing in mind I'm on the compact framework, does anyone have any suggestions how i can check the file ?
1
3009
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 known problem? -------------------------------------------------------------------------- using System; using System.Xml;
2
9122
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 xmlns="http://LandAm.EAI.Mainframe.TSR.Schemas.TSSCallback"> <orderNo xmlns="">string</orderNo> <customerId xmlns="">string</customerId> <taxingAuthorityList xmlns=""> <string>string</string> <string>string</string>
4
4753
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"/> <x:include href="more.xml"/> </Main> i tried to use xmlnamespacemanager and also to declare the namespace
1
2739
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 consuming. I keep getting the following error when I submit my email to their site. System.Xml.Xsl.XslTransformException: Cannot find the script or external object that implements prefix 'ext:MailingList'. at...
3
10430
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 "ResultNodes" as System.Xml.XmlElements but when I try and serialize (serialise) my result object I get the following exception: "System.InvalidOperationException" - "There was an error generating the XML document" "The type System.Xml.XmlElement...
12
1556
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 using XmlWriter, there is one line that I can't figure out how to generate: <ServicesCertifiedMail="OFF" DeliveryConfirmation="ON" ></Services> I've tried several different combinations of methods and can't seem to generate that string. Is it...
1
1281
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
5238
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> <element2>value</element2> <element3>value</element3> <element4>value</element4>
0
8356
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8871
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8783
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8552
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7387
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5666
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4198
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4369
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1776
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.