Asp.net implements the xml output method,
This example describes how to implement the output xml in asp.net. We will share this with you for your reference. The details are as follows:
# Region Query and modify the value of an xml Node Based on the xml node // <summary> // query and modify the value of an xml Node Based on the xml node // </summary> /// <param name = "fileName"> name of the xml file to be loaded </param> /// <param name = "tagName"> name of the xml node </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 ;}}}} catch {}# endregion # region Save the modified xml file content // Save the modified xml file content public void SaveXml (st Ring fileName) {doc. save (Server. mapPath (fileName) ;}# endregionstring selNodeName = "// url/data"; string fileName = "meituanAPI. xml "; parameters (fileName, selNodeName," website "," "); GetXmlbySelNodel (fileName, selNodeName," siteurl "," Parameters "); GetXmlbySelNodel (fileName, selNodeName, "city", "Hangzhou"); GetXmlbySelNodel (fileName, selNodeName, "tip", "ipad Lucky Draw !! "); GetXmlbySelNodel (fileName," // data/shops "," name "," Shanghai zhouxin 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 design your asp.net program.
Articles you may be interested in:
- Detailed description of xml file instance generated by asp.net class serialization
- How to add, delete, modify, and query XML in asp.net
- ASP. NET XmlDocument
- Example of XML-to-JSON method conversion in ASP. NET
- Example of adding, deleting, and modifying xml operations in asp.net
- Asp.net TreeView and XML generate a list tree in three steps
- Analysis on how ASP. NET + XML creates a network Hard Disk
- Analysis of Four Methods for ASP. NET to read XML files
- Implementation of XML encryption and decryption in asp.net
- Asp.net uses XML to generate a scalable custom tree
- Asp.net XML file operation implementation code