نحوه ایجاد نود با کد C#.
if (!File.Exists(Server.MapPath("xml3.xml")))
{
XmlTextWriter textWritter = new XmlTextWriter(Server.MapPath("xml3.xml"), null);
textWritter.WriteStartDocument();
textWritter.WriteStartElement("News");
textWritter.WriteEndElement();
textWritter.Close();
}
//================================================== ==
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(Server.MapPath("xml3.xml"));
XmlElement subRoot = xmlDoc.CreateElement("NewsItem");
//UserName
XmlElement appendedElementImageUrl = xmlDoc.CreateElement("Title");
XmlText xmlTextImageUrl = xmlDoc.CreateTextNode(txtTitle.Text);//Ali jan 1 text box be name txtTitle to form besaz
appendedElementImageUrl.AppendChild(xmlTextImageUr l);
subRoot.AppendChild(appendedElementImageUrl);
xmlDoc.DocumentElement.AppendChild(subRoot);
//Email
XmlElement appendedElementText = xmlDoc.CreateElement("Date");
XmlText xmlTextText = xmlDoc.CreateTextNode(DateTime.Now());//inja tarikhe emroz miad .mitonid az textbox estefade konid.
appendedElementText.AppendChild(xmlTextText);
subRoot.AppendChild(appendedElementText);
xmlDoc.DocumentElement.AppendChild(subRoot);
xmlDoc.Save(Server.MapPath("xml3.xml"));// save kardane file
// Xml1.DataBind();//agar az control xml estefade mikonid mitonid ono entesab bedid be file xml va namayesh dahid dar gheire in sorat nemikhad. in khat ro estefade konid.