Token StartElement in state Epilog would result in an invalid XML document

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jatinvmehta
    New Member
    • Mar 2008
    • 6

    Token StartElement in state Epilog would result in an invalid XML document

    Hi,

    I am using dataset to read a xml file.

    dsData.ReadXml( ConfigurationSe ttings.AppSetti ngs["xmlpath"].ToString());

    i am binding this dataset to a datagrid.

    Then i add a new row to dataset

    DataRow dr = dsData.Tables[1].NewRow();
    dr["ID"] = dsData.Tables[1].Rows.Count;
    dr["Numeric-3"] = txtNumeric3.Tex t;
    dr["Alpha-2"] = txtAlpha2.Text ;
    dr["Alpha-3"] = txtAlpha3.Text ;
    dr["English Short Name"] = txtEShort.Text ;
    dr["English Full Name"] = txtEFull.Text ;
    dr["French Short Name"] = txtFShort.Text ;
    dr["French Full Name"] = txtFFull.Text ;
    dsData.Tables[1].Rows.Add(dr);
    dsData.AcceptCh anges();

    And finally, i tried to save xml.

    if ( File.Exists(Con figurationSetti ngs.AppSettings["xmlpath"].ToString()))
    File.Delete(Con figurationSetti ngs.AppSettings["xmlpath"].ToString());
    dsData.WriteXml (ConfigurationS ettings.AppSett ings["xmlpath"].ToString());


    I delete existing XML file and try to create new one.

    When i tried to write xml, it gives me this error.

    Please advice.

    Thanks in advance.

    Jatin
  • vijay
    New Member
    • Aug 2006
    • 31

    #2
    Hi Jatin urfe RAM,

    This is Vijay Vaja........... how r u man........i have not much clue on this....but some windows file problem i faced earlier and from there i can tell that.......prob lem could be you are deleting the file and immediately trying to create the same file on same path.....where system is creating some problem (invalid state).....

    Instead deleting and creating new one.........you use option of create file directly (there must be some option to pass as overwrite the file if already exist and avoid manual deletion).

    Let me know if this helps....

    Regards,
    ...Vijay
    Originally posted by jatinvmehta
    Hi,

    I am using dataset to read a xml file.

    dsData.ReadXml( ConfigurationSe ttings.AppSetti ngs["xmlpath"].ToString());

    i am binding this dataset to a datagrid.

    Then i add a new row to dataset

    DataRow dr = dsData.Tables[1].NewRow();
    dr["ID"] = dsData.Tables[1].Rows.Count;
    dr["Numeric-3"] = txtNumeric3.Tex t;
    dr["Alpha-2"] = txtAlpha2.Text ;
    dr["Alpha-3"] = txtAlpha3.Text ;
    dr["English Short Name"] = txtEShort.Text ;
    dr["English Full Name"] = txtEFull.Text ;
    dr["French Short Name"] = txtFShort.Text ;
    dr["French Full Name"] = txtFFull.Text ;
    dsData.Tables[1].Rows.Add(dr);
    dsData.AcceptCh anges();

    And finally, i tried to save xml.

    if ( File.Exists(Con figurationSetti ngs.AppSettings["xmlpath"].ToString()))
    File.Delete(Con figurationSetti ngs.AppSettings["xmlpath"].ToString());
    dsData.WriteXml (ConfigurationS ettings.AppSett ings["xmlpath"].ToString());


    I delete existing XML file and try to create new one.

    When i tried to write xml, it gives me this error.

    Please advice.

    Thanks in advance.

    Jatin

    Comment

    • jasminmashru
      New Member
      • Mar 2008
      • 1

      #3
      Hi Jattu,

      How r u ?
      I tried to execute ur code except the step of binding GRID, its working fine.

      Could u plz send me the error description ?

      Thanks
      Jasmin

      Comment

      Working...