BALU REDDY

BALU REDDY

  • NA
  • 1
  • 1.2k

regarding xml file creation using form

Jun 19 2013 3:16 AM

The XML page cannot be displayed

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


A name contained an invalid character. Error processing resource 'file:///D:/Training/XMLrelated/XMLrelated/bin/Debug/Issue...

<?xml version="1.0" encoding="utf-8"?><Root><IssueList><Issue><Subject>gajgn</Subject>&l...

i am getting the above error while trying to create xml file using xmlwriter can anyone plz help out regarding the issue..

and my code goes like this....just check it out


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Xml;


namespace XMLrelated
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void btnSubmit_Click(object sender, EventArgs e)
        {
            XmlTextWriter writer = new XmlTextWriter("Issues.xml",Encoding.UTF8);
            writer.WriteStartDocument();
            
            writer.WriteStartElement("Root");
            
            writer.WriteStartElement("IssueList");
            
            writer.WriteStartElement("Issue");
            
            writer.WriteStartElement("Subject");
            writer.WriteString(txtSubject.Text);
            writer.WriteEndElement();  //Subject
            
            writer.WriteStartElement("Description");
            writer.WriteString(txtDescription.Text);
            writer.WriteEndElement();  // Description
            
            writer.WriteStartElement("Source");
            writer.WriteString(txtSource.Text);
            writer.WriteEndElement();  //Source
            
            foreach (string attachment in txtAttachments.Text.Split(','))
            {
                writer.WriteStartElement("Attachments");
                writer.WriteString(attachment);
                writer.WriteEndElement();  //Attachments
            }
            
            writer.WriteStartElement("Date Received");
            writer.WriteString(txtDateReceived.Text);
            writer.WriteEndElement();       //Date Received
            
            foreach (string comments in txtComments.Text.Split(','))
            {
                writer.WriteStartElement("Comments");
                writer.WriteString(comments);
                writer.WriteEndElement();  //Comments
            }
            
            writer.WriteStartElement("Solution");
            writer.WriteString(txtSolution.Text);
            writer.WriteEndElement();    //Solution
            
            writer.WriteStartElement("Status");
            writer.WriteString(txtStatus.Text);
            writer.WriteEndElement();    //Status
            
            writer.WriteStartElement("Date Closed");
            writer.WriteString(txtDateClosed.Text);
            writer.WriteEndElement();   //Date closed

            writer.WriteEndElement();   //Issue

            writer.WriteEndElement();   //IssueList

            writer.WriteEndElement();   //Root

            writer.WriteEndDocument();  //Main document close

            writer.Close();

        }
    }
}


and my xml file should look like 
<root>
   <Issuelist>
       <Issue>
          <subject>  </subject>
          <Description>       </Description>
          <Source>           </Source>
          <Attachments>
             <attachment>
             </attachment>
             <attachment>
             </attachment>
             .... 
                  ....
             </Attachments>
            <Date closed>     </Date closed>
             <comments>
                    <comment>    </comment>
                    <comment>     </comment>
                    ....
                    ...
            </comments>
           <solution>         </solution>
          <status>           </status>
           <Dateclosed>         </Dateclosed>
        </Issue>
      </IssueList>
      </root>


plz help me out....

Thanks in advance....
            
          

Answers (1)