XML ASP.Net

<%--
Code Revised from
       
Professional ASP.NET 2.0 XML (Programmer to Programmer) (Paperback)
by Thiru Thangarathinam 
# Publisher: Wrox (January 18, 2006)
# Language: English
# ISBN: 0764596772
--%>
<%@ Page Language="C#" %>
<%@ Import Namespace="System.Xml" %>
   
    protected void btnSave_Click(object sender, EventArgs e)
    {
        string xmlPath = MapPath("Books2.xml");
        XmlDocument doc = new XmlDocument();
        if (System.IO.File.Exists(xmlPath))
        {
            doc.Load(xmlPath);
            XmlNode bookNode = CreateBookNode(doc);
            //Get reference to the book node and append the book node to it
            XmlNode bookStoreNode = doc.SelectSingleNode("bookstore");
            bookStoreNode.AppendChild(bookNode);
        }
        else
        {            
            XmlNode declarationNode = doc.CreateXmlDeclaration("1.0", "", "");
            doc.AppendChild(declarationNode);
            XmlNode comment = doc.CreateComment("Comments Here");
            doc.AppendChild(comment);            
            XmlNode bookstoreNode = doc.CreateElement("bookstore");
            XmlNode bookNode = CreateBookNode(doc);                        
            bookstoreNode.AppendChild(bookNode);
            doc.AppendChild(bookstoreNode);
        }
        lblResult.Text = "XML Document has been successfully created";
        doc.Save(xmlPath);
    }
    XmlNode CreateBookNode(XmlDocument doc)
    {
        XmlDocumentFragment docFragment = doc.CreateDocumentFragment();
        docFragment.InnerXml = "" + 
                             "" + txtTitle.Text +" " +
                               "" + txtFirstName.Text + "" +
                               "" + txtLastName.Text + "
" +
                               "" + txtPrice.Text + "";
        return docFragment;
    }
    



    Creating an XmlDocumentFragment


    
    
        
        
            
                
                    Book Details:
                                               
            

            
                
                    Genre:
                
                
                    
                
            

             
                
                    Title:
                
                
                    
                
            

            
                
                    First Name:
                
                
                    
                
            

            
                
                    Last Name:
                
                
                    
                
            

            
                
                    Price: