You must Sign In to post a response.
  • Category: XML

    How do i save asp.net webpage textbox element values into xml

    I have a scenario where i need to save the textbox values into xml and then save that xml into sql server 2005.

    I will try to give you an example here.....i have a webpage which has got all textboxes and a save button. The moment a user enters the values in those textboxes and clicks on the save button, the values in the textboxes should be saved as XML and then the XML should be saved in SQL server 2005. So here two things should happen.

    1) values in the textboxes should be saved into XML

    2) XML should be saved into SQL Server

    I have gone through few website links, but didn't get much help. I thought, this is the right forum which could help me out. I really need your input guys.....if possible, if you could give me a sample code, i would be more than happy.

    Would be eagerly and desparately waiting for your replies as soon as possible
  • #369697
    hope this will help you out

    http://functionx.com/vcsharp2003/xml/Lesson02.htm

  • #369865
    hi,

    u can create a xm file as follows and after the creation using the XML data type in the data base u can save the xml file...


    public void createXML()
    {
    XmlDocument doc = new XmlDocument();


    string filename="c:\\sample.xml";
    XmlTextWriter tw=new XmlTextWriter(filename,null);//null represents the Encoding Type//
    tw.Formatting=Formatting.Indented; //for xml tags to be indented//

    //tw.WriteStartDocument(); //Indicates the starting of document (Required)//


    //tw.WriteStartElement("Employees");
    //tw.WriteStartElement("Employee","Genius");
    //tw.WriteAttributeString("Name","krishnan");
    //tw.WriteElementString("Designation","Software Developer");
    //tw.WriteElementString("FullName","krishnan Lakshmipuram Narayanan");

    tw.WriteStartElement("Author");
    tw.WriteElementString("ID","1");
    tw.WriteElementString("SubmissionDate","1-1-08");
    tw.WriteElementString("Topic","test");
    tw.WriteElementString("Title","test");
    tw.WriteStartElement("Authors");
    tw.WriteStartElement("Author");
    tw.WriteElementString("Name","XYZ");
    tw.WriteElementString("Affiliation","ABC");
    tw.WriteEndElement();
    tw.WriteEndElement();
    tw.WriteElementString("Summary","Hi");
    tw.WriteElementString("Text","Hello");

    tw.WriteEndElement();
    //tw.WriteEndDocument();
    tw.Flush();
    tw.Close();

    StreamReader srXml = new StreamReader(filename);
    string xmlFile = srXml.ReadToEnd();



    }


    Thanks & Regards
    Anil Kumar Pandey
    Microsoft MVP, DNS MVM


  • This thread is locked for new responses. Please post your comments and questions as a separate thread.
    If required, refer to the URL of this page in your new post.