ERROR:Token StartElement in state Epilog would result in an invalid XML document RRS feed

  • Question

  • hi every one

    i got a error when i tried to write xml file from the dataset. All elements of xml are populated run time in the dataset except --dataset shows on new row 'SupportItems_Id' which is not exist in the xml file.

    this is the code-----
    if (strAlbumName != "" && strAlbumPath != "")
                    strXMLFile = strAlbumPath + "\\" + strAlbumName + ".linkinfo.xml";
                    XmlDocument doc = new XmlDocument();
                    System.Data.DataSet objDataSet = new DataSet();
                    for (int i = 0; i < objDataSet.Tables.Count - 1; i++)
                        if (objDataSet.TablesIdea.TableName == "ScreenSupportItem")
                            for (int j = 0; j < objDataSet.TablesIdea.Rows.Count; j++)
                                if (Convert.ToInt32(objDataSet.TablesIdea.Rows[j]["RefId"]) == 3)
                                    string strFilePath = FileUpload.PostedFile.FileName;
                                    DataRow newrow = objDataSet.TablesIdea.NewRow();
                                    newrow["LinkDate"] = System.DateTime.Today;
                                    newrow["LinkAuthor"]= "SUBHASH\\Login Subhash";
                                    newrow["LinkURL"] = FileUpload.PostedFile.FileName;
                                    newrow["LinkText"] = txtUrlTitle.Text;
      newrow["OptionalSupportInstruction"] = "Nothing";
                                    newrow["RefId"] = 3;

    and these are the few lines of  xml file--

              <LinkAuthor>SUBHASH\Login Subhash</LinkAuthor>
              <LinkText>Testing Help file</LinkText>
              <OptionalSupportInstruction />

    I am new in xml , any body please try to solve my problem
    Thanks in advance.

    Monday, November 5, 2007 11:23 AM

All replies

  • I think your problem isn't Xml related but comes from the way you use the DataSet. I copied your code and the input you provided (had to fix it up some) and then put a break point at this statement:

    Code Block



    If you evaluate this in the QuickWatch window you'll see that it returns non-well formed Xml. If you examine the value in the text visualizer, you'll see that the Xml you get is

    Code Block









    The last three lines corresond to the new row inserted (I dumbed it down some) -- in other words, the new row gets serialized as a sibling to the root element. This is exactly why the writer is giving the error you're seeing.


    I couldn't quickly figure out the proper way to add your data row -- maybe someone else here can help or you could try the folks on the Data Access forum:


    Thursday, December 27, 2007 4:52 AM