Increase:
usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text.RegularExpressions;usingsystem.web;usingSystem.Xml;namespaceappservice{ Public classXMLReader { Public Static voidXmlmake (stringindesstring) { Try { strings =indesstring; string[] resultstring = S.split ('|'); foreach(stringIinchresultstring) {} XmlDocument Doc=NewXmlDocument (); XmlDeclaration Dec= Doc. Createxmldeclaration ("1.0","UTF-8",NULL); Doc. AppendChild (DEC); //Create a root node (first level)XmlElement root = doc.createelement_x ("Jokes"); Doc. AppendChild (root); //Create nodes (level two)XmlNode node = doc.createelement_x ("Tag"); //Create nodes (level three)XmlElement element1 = doc.createelement_x ("Shenchang"); //element1. SetAttribute ("Name", "Sam"); //element1. SetAttribute ("ID", "665");Element1. InnerText = resultstring[0]; Node. AppendChild (ELEMENT1); XmlElement Element2= Doc.createelement_x ("Tizhong"); //Element2. SetAttribute ("Name", "Round"); //Element2. SetAttribute ("ID", "678");Element2. InnerText = resultstring[1]; Node. AppendChild (Element2); XmlElement Element3= Doc.createelement_x ("BMI"); //Element2. SetAttribute ("Name", "Round"); //Element2. SetAttribute ("ID", "678");Element3. InnerText = resultstring[2]; Node. AppendChild (ELEMENT3); Root. AppendChild (node); stringp = AppDomain.CurrentDomain.BaseDirectory +"Version1"; Doc. Save (P+"\\ABC.xml"); Console.Write (Doc. OuterXml); } Catch { } } }}
Change:
usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingsystem.web;usingSystem.Xml;namespaceappservice{ Public classXmlwrite { Public Static voidxmlupdate (String indesstring) {strings =indesstring; string[] resultstring = S.split ('|'); Try{XmlDocument xmldoc=NewXmlDocument (); stringp = AppDomain.CurrentDomain.BaseDirectory +"Version1"; Xmldoc.load (P+"\\ABC.xml"); XmlNode Xns= Xmldoc.selectsinglenode ("Jokes"); XmlNodeList XNL=Xns. ChildNodes; foreach(XmlNode xninchxnl) {XmlElement XE=(XmlElement) xn; XmlNodeList XNL2=XE. ChildNodes; foreach(XmlNode xn2inchxnl2) {XmlElement Xe2=(XmlElement) xn2; if(Xe2. Name = ="Shenchang") {Xe2. InnerText= resultstring[0]; } if(Xe2. Name = ="Tizhong") {Xe2. InnerText= resultstring[1]; } if(Xe2. Name = ="BMI") {Xe2. InnerText= resultstring[2]; }}} xmldoc.save (P+"\\ABC.xml"); } Catch { } } }}
"C #" How to create an XML file and an XML file to add and change