private void SaveRss()
string {
try
{
}}}}}}}}}}}}}} · · ····································· = “rss version=”+2.0;
FileInfo file = new FileInfo(Server.MapPath(“rss.xml”));
If (!file.Exists){
Writer(text.Writer) Xml Xml Server.MapPath(“rss.xml”), System.Text.Encoding.UTF8);
Begin the writing process, call the WriteStartDocument method to write the file header information such as
TextWriter.WriteStartDocument();
. Write to the root node textWriter.WriteStartElement ( “channel”); p> // write node title // written into the node item // close textWriter Get text information // Get the text information Add each node that stores information created above to the menber node but does not include the final value of the parent App End Child( parent nameNode); Add the text information obtained above to the corresponding Xdoc.Save(Server.MapPath(“rss.xml”));
textWriter.WriteStartElement ( “title”, “”);
textWriter.WriteString ( “China Tibet Medical Hotline”);
TextWriter.WriteEndElement ();
// written into the node link
textWriter.WriteStartElement ( “link”, “”);
textWriter.WriteString ( “http://www.cacaos.net”) ;
textWriter.WriteEndElement ();
// write node description
textWriter.WriteStartElement ( “description”, “”);
textWriter.WriteString ( “China Tibetan medicine hotline, Tibetan medicine knowledge consulting, product ordering service! “);
textWriter.WriteEndElement ();
// write node pubDate
textWriter.WriteStartElement (” pubDate “,” “);
textWriter.WriteString (DateTime .Now.ToString ());
textWriter.WriteEndElement (); p>
textWriter.WriteStartElement ( “item”);
// write node title
textWriter.WriteStartE lement ( “title”, “”);
textWriter.WriteString ( “China Tibetan Medicine Hotline”);
textWriter.WriteEndElement ();
// write node link
textWriter.WriteStartElement ( “link”, “”);
textWriter.WriteString ( “http://www.cacaos.net”);
textWriter.WriteEndElement ();
// node written description
textWriter .WriteStartElement(“description”, “”);
textWriter.WriteString(“Chinese Tibetan medicine hotline, Tibetan medicine knowledge consultation, product ordering service!”);
End textWriter. write node pubDate
textWriter.WriteStartElement ( “pubDate”, “”);
textWriter.WriteString (DateTime.Now.ToString ());
textWriter.WriteEndElement ();
// write Entry node author
textWriter.WriteStartElement(“author”, “”); textWriter.WriteString ( “Ho”);
textWriter.WriteEndElement ();
// write terminator
textWriter.WriteEndElement item node ();
p> < p> // write end of the document, calling WriteEndDocument method
textWriter.WriteEndDocument (); p>
textWriter.Close ();
}
else
{
SaveXMLData_nodemode ();
}
// show all users message
//Response.Redirect(“viewphonebook_reader.aspx “);
}
catch {< br> ClientScript.RegisterStartupScript(typeof(string),””,”“);
}
#Region Generate RSS (write XML in node mode)
private void SaveXMLData_nodemode()
{
try
{
Create an XmlDocument object to load an XML file for storing information
XmlDocument xdoc = new XmlDocument();
xdoc.Load(Server.MapPath(“rs.xml); br> Create a new menber node and add it under the root node
XmlElement parentNode = xdoc.CreateElement(“member”);
Xdoc.CreateElement(“member”);
Xdoc.Element.Prepend() xdoc.DocumentElement.Prepend() Create all nodes used to store information
XmlElement nameNode = xdoc.CreateElement(“name”);
XmlElement telphoneNode = xdoc.CreateElement(“telphone”);
Xml Element( qqElement Xml. qq Element) “);
XmlElement msnNode = xdoc.CreateElement(“msn”);
XmlElement cellphoneNode = xdoc.CreateElement(“cellphone”);
CreateElement(“cellphone”);
CreateElement(“cellphone”);
XmlElement work( xmlElement work” xmlDoc” > XmlElement addressNode = xdoc.CreateElement(“address”);
XmlElement emailNode = xdoc.CreateElement(“email”);
XmlText nameText = xdoc.CreateTextNode(Request.Form.Get(“name”));
XmlText telphoneText = xdoc.CreateTextNode(Request.Form.Get(“telphone”));
XmldocText.CreateText qqText = xmldocText qqText (Request.Form.Get(“qq”));
XmlText msnText = xdoc.CreateTextNode(Request.Form.Get(“msn”));
XmlText cellphoneText = xdoc.CreateTextNode(Request.Form.Get (“cellphone”));
XmlText workText = xdoc.CreateTextNode(Request.Form.Get(“work”));
XmlText addressText = xdoc.CreateTextNode(Request.Form.Get(“address”)) ;
XmlText emailText = xdoc.CreateTextNode(Request.Form.Get(“email”)); */
CreateText Name(xmlText name) );
XmlText telphoneText = xdoc.CreateTextNode(“telphone”);
XmlText qqText = xdoc.CreateTextNode(“qq”);
CreateTextNode(“qq”);
TextNode(CreateTextNode(“qq”) xmlText msn” xmldoc. “);
XmlText cellphoneText = xdoc.CreateTextNode(“cellphone”);
XmlText workText = xdoc.CreateTextNode(“work”);
CreateTextNode(“work”);
Text address(xml”Text address(xml”TextNode); > XmlText emailText = xdoc.CreateTextNode(“email”);
ParentNode.AppendChild(telphoneNode);
ParentNode.AppendChild(qqNode);
ParentNode. Child( parentNode.AppendChild(msnNode); ParentNode( parentNode.AppendChild(msnNode); ParentAppendChild(msnNode);
workNode);
parentNode.AppendChild(addressNode);
parentNode.AppendChild(emailNode);
nameNode.AppendChild(nameText);
telphoneNode.AppendChild(telphoneText);
qqNode.AppendChild(qqText);
msnNode.AppendChild(msnText);
cellphoneNode.AppendChild(cellphoneText);
workNode.AppendChild(workText);
addressNode.AppendChild(AppendChild)(AppendText); TextNode(AppendMail);TextNode(AppendMail);TextNode(AppendMail); >
.Redirect(“viewphonebook_reader.aspx”);
}
Catch (Exception se) {Console.WriteLine(se.Message); }
}
P} #endregion
/********************************************** *****************/
#region Opinion survey
protected void Button1_Click(object sender, EventArgs e)
{
/ /load xml file
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(Server.MapPath(“vode.xml”));
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(Server.MapPath(“vode.xml”));
String vOne = RadioButtonList1. r> string vSen = RadioButtonList2.SelectedItem.Text;
XmlNodeList nodeLis = xmlDoc.SelectSingleNode ( “root / vode”) ChildNodes;. p>
try {if (vOne == “favor”) nodeLis [ 0].InnerText = (Convert.ToInt32(nodeLis[0].InnerText) + 1).ToString(); else else else InnerText = (Convert.ToInt32(nodeLis[0].InnerText) + 1). nodeLis[1].InnerText = (Convert.ToInt1). (); If (vSen == “Kind”) nodeLis[2].InnerText = (Convert.ToInt32(nodeLis[2].Inner Text) + 1).ToString(); Inner Text) + 1).ToString(); Inner Text) + 1).ToString(); [3].InnerText = (Convert.ToInt32(nodeLis[3].InnerText) + 1).ToString(); else else Else InnerText = (Convert.ToInt32(nodeLis[3].InnerText) + 1) nodeLis[4].InnerText = (Convert.ToInt4). ToString(); Catch {} Finally {}}}}}}}}}}}}}}}}}}} ”Catch {}” ”Finally” xml Doc. ”Save xmlPath(” vo” xmlDoc.) (Server. xmlDoc.) (Server. entScript.RegisterStartupScript(typeof(string), “jyu”, ““); #endregion