Passing Data Through Controls
[.aspx.cs file]
Including library-
using System.Xml;
Creating Objects of Some Classes-
1. XmlDocument // used to open the xml file
2. XmlNode // used to read the first node
3. XmlElement // reads the sub root
XmlDocument xdocx = new XmlDocument();
// the xml file willl be loaded in the object(xdocx)
xdocx.Load(Server.MapPath("Xml_file_name.xml"));
// The root will be stored in the object
XmlNode xnode = xdocx.DocumentElement.FirstChild;
// sub root will be stored
XmlElement xele = xdocx.CreateElement("subroot");
// bind the attributes with controls
xele.SetAttribute("Attribute_name", Server.HtmlEncode(Control_id.Text));
...
// HtmlEncode is used to connect with the dot net controls because the xml is in html format
//Filling the inner text
xele.InnerText = Server.HtmlEncode(control_name);
// the data to be inserted before or after the previous record
xdocx.DocumentElement.InsertBefore(xele,xnode);
xdocx.Save(Server.MapPath("xml_file_name.xml"));
Comments
Post a Comment