The example in this article describes how asp.net implements the output XML. Share to everyone for your reference, specific as follows:
#region Query XML node values based on XML nodes and make modifications///<summary>///Query XML node values based on XML nodes and make modifications///</summary>///<param name= "file Name > XML file to load </param>///<param name= "TagName" >xml node names </param>///<param name= " Newxmltext "> Modified value </param>///<returns></returns> public void Getxmlbyselnodel (string fileName, String Selnodename, String tagname,string newxmltext) {try {doc.
Load (Server.MapPath (fileName)); XmlNodeList nodelist = doc. Documentelement.selectsinglenode (Selnodename).
ChildNodes;
foreach (XmlNode node in nodelist) {XmlElement xle = node as XmlElement; XmlNodeList list = Xle.
ChildNodes; for (int j = 0; J < list.) Count; J + +) {if (xle). CHILDNODES[J]. Name = = tagName) {xle. CHILDNODES[J].
innertext = Newxmltext;
SaveXML (FileName);
Break
#endregion #region Save the modified XML file contents after saving modified XML file contents public void SaveXML (string fileName) { Doc. Save (Server.MapPath (fileName));
} #endregion string Selnodename= "//url/data";
String fileName = "Meituanapi.xml";
Getxmlbyselnodel (FileName, Selnodename, "website", "cloud-dwelling community");
Getxmlbyselnodel (FileName, Selnodename, "SiteURL", "www.jb51.net");
Getxmlbyselnodel (FileName, Selnodename, "City", "Hangzhou");
Getxmlbyselnodel (FileName, Selnodename, "Tip", "Send the ipad lottery!!");
Getxmlbyselnodel (FileName, "//data/shops", "name", "Shanghai Chau Xin Information Technology Co., Ltd.!");
DataSet ds = new DataSet (); Ds.
READXML (Server.MapPath ("Meituanapi.xml"));
XmlTextWriter writer = new XmlTextWriter (Response.outputstream, response.contentencoding); Ds. Tables[0].
WriteXml (writer);
Response.ContentType = "text/xml;charset=gb2312";
Response.Flush ();
Response.End ()
Or
Response.clearcontent ();
Response.ClearHeaders ();
Response.contenttype= "Application/xml";
Response.writerfile (Server.MapPath ("Api/54tuanapi.xml"));
Response.Flush ();
Response.End ();
I hope this article will help you to ASP.net program design.