1. We have moved from vBulletin to XenForo and you are viewing the site in the middle of the move. Though the functional aspect of everything is working fine, we are still working on other changes including the new design on Xenforo.
    Dismiss Notice

Error saving list items in XML

Discussion in 'C#' started by shah123, May 18, 2007.

  1. shah123

    shah123 New Member

    I am getting this error when i add xml code to my application. Basically I am trying to add listitems to XML file.

    Code:
    private const string filename = "C:\\schedulers.xml";            
    XmlTextWriter sch = null;
                sch = new XmlTextWriter(filename, null);
                sch.Formatting = Formatting.Indented;
                sch.Namespaces = false;
    try
                    {
                        sch.WriteStartDocument();
    
                        sch.WriteStartElement("", "Schedules", "");
    
                        sch.WriteStartElement("", "Scheduler", "");
                        sch.WriteString(subjTextbox.Text.ToString());
                        sch.WriteEndElement();
    
                        sch.WriteStartElement("", "FileName", "");
                        sch.WriteString(textFile.Text.ToString());
                        sch.WriteEndElement();
    
                        sch.WriteStartElement("", "Date & Time", "");
                        sch.WriteString(date.ToString());
                        sch.WriteEndElement();
    
                        sch.WriteEndElement();
                        sch.Flush();
                    }
                    catch (Exception e1)
                    {
                        MessageBox.Show(e1.Message);
    
                    }
    

    Error:

    Cannot view XML input using XSL style sheet. Please correct the error and then click the Refresh button, or try again later.


    --------------------------------------------------------------------------------

    A name was started with an invalid character. Error processing resource 'file:///C:/schedulers.xml'. Line 5, Position 9

    <Date & Time>18/05/2007 02:02:00</Date & Time>
    --------^


    please help
     
  2. shabbir

    shabbir Administrator Staff Member

    probably the node should be without space or &
     
  3. shah123

    shah123 New Member

    Yup It Worked .. Thanks
     

Share This Page