TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
k
NA
25
0
Problem with XmlTextWriter
May 23 2009 6:34 PM
I had the code to write data into xml file. But I got 01 error when running. But I don't know why. Please show me the reason.
/////////////////////////WRITE TO XML FILE/////////////////////////////
XmlTextWriter myXmlTextWriter = new XmlTextWriter("manchester_united.xml", null);
myXmlTextWriter.Formatting = Formatting.Indented;
myXmlTextWriter.WriteStartDocument(false);
myXmlTextWriter.WriteDocType("bookstore", null, "books.dtd", null);
myXmlTextWriter.WriteComment("my data");
myXmlTextWriter.WriteStartElement("Data");
string getString = "";
int n;
flag = 0;
for (int i = 0; i < countLink; i++)
{
for (n = 0; n < url.Length; n++)
{
if (link[i]._originalLink == url[n].link)
{
flag = 1;
break;
}
}
if (flag == 1)
{
myXmlTextWriter.WriteStartElement("WebPage", null);
//When i ==0, there was no error, but when i ==1, I got error in this line
(*)
myXmlTextWriter.WriteAttributeString("Index", i.ToString());
myXmlTextWriter.WriteAttributeString("RootSet", "True");
myXmlTextWriter.WriteStartElement("Link");
myXmlTextWriter.WriteAttributeString("Title", "");
myXmlTextWriter.WriteString(url[n].link);
myXmlTextWriter.WriteEndElement();
for (int j = 0; j < link[i]._countEmbeddedLink; j++)
for (int m = 0; m < url.Length; m++)
{
if (url[m].link == link[i]._embeddedLink[j])
getString = getString + m.ToString() + " ";
}
myXmlTextWriter.WriteElementString("List", getString);
myXmlTextWriter.WriteEndElement();
}
}
myXmlTextWriter.WriteEndElement();
myXmlTextWriter.Flush();
myXmlTextWriter.Close();
(*)
the error is:
An unhandled exception of type 'System.InvalidOperationException' occurred in System.Xml.dll
Additional information: Token StartElement in state Epilog would result in an invalid XML document.
Thanks all in advance.
Reply
Answers (
0
)
Listview.TopItem is Very slow on First Execution
how to write insert query to insert combobox text to msaccess database