Project compatibility requires the generation of a series of XML files, which summarizes the basic XML file generation method XmlTextWriterw = newXmlTextWriter (C: \ XML file name. xml, Encoding. unicode); // Encoding. unicode is the encoding format used to generate XML files, which can be combined with the output:
Project compatibility requires generating a series of XML files, which summarizes the basic methods for generating XML files.
XmlTextWriter w = new XmlTextWriter ("C: \ XML file name. xml", Encoding. Unicode); // Encoding. Unicode indicates the Encoding format of the generated XML file, which is combined with the output:
W. Formatting = Formatting. Indented; // This attribute indicates that the content in the xml file is Indented by level.
// Start generating the file content below
W. WriteStartDocument (); // start to write xml. at the end, there is a matching w. WriteEndDocument ();
W. WriteStartElement ("SpotList ");
W. WriteAttributeString ("xmlns: xsi", "http: www.w3.org/2001/XMLSchema-instance"); // SpotList node attributes
W. WriteAttributeString ("xmlns: xsd", "http: www.w3.org/2001/XMLSchema"); // SpotList node attribute, final effect:
W. WriteStartElement ("Items ");
W. WriteElementString ("Name", myPoints [j]. Name );
W. WriteElementString ("Caption", myPoints [j]. Caption );
W. WriteElementString ("Addr", myPoints [j]. Addr );
W. WriteElementString ("Phone", myPoints [j]. Phone );
W. WriteStartElement ("Intro"); // The final effect is as follows: 相关内容
W. WriteCData (myPoints [j]. Intro );
W. WriteEndElement ();
W. WriteEndElement ();
W. WriteEndElement ();
W. WriteEndDocument ();
W. Close (); // complete the output of the xml file, Close