Simple XML control: After an XML file is created, the following code is copied to the button event and compiled and executed to generate Pos in the corresponding physical path. the following content is referenced in the xml file: XmlTextWriterxtw = newXmlTextWriter (Request. physicalApplicationPath
Simple XML control: creation of XML files
Copy the following code to the button event. after compilation, the code can be generated in the corresponding physical path.Pos. xmL file
Reference content is as follows:
XmlTextWriter xtw = new XmlTextWriter (Request. PhysicalApplicationPath "Pos. xml", System. Text. Encoding. UTF8 );
Xtw. Formatting = Formatting. Indented;
Xtw. WriteStartDocument (false );
// Result:
Xtw. WriteComment ("Pos Infomation ");
// Document comments:
Xtw. WriteStartElement ("Info ");
// XML Root node results:
Xtw. WriteStartElement ("Zc", null );
// XML element 1 result:
Xtw. WriteElementString ("kmdm", "0301 ");
// XML element 1 key result: 0301
Xtw. WriteElementString ("scbj", "1 ");
// XML element 1 key value result: 1
X tw. WriteElementString ("zy", "100 ");
// XML element 1 key result: 100
Xtw. WriteEndElement ();
// End result of XML element 1:
Xtw. Flush ();
Reference content is as follows:
Xtw. WriteStartElement ("PosInfo", null );
// XML element 2 results:
Xtw. WriteAttributeString ("kpid", "030100111 ");
Xtw. WriteAttributeString ("PosX", "289 ");
Xtw. WriteAttributeString ("PosY", "47 ");
// XML element 2 attributes:
Xtw. WriteEndElement ();
// End result of XML element 2:
Xtw. WriteEndElement ();
// XML Root end result:
Xtw. Flush ();
Xtw. Close (); // release resources
Note: The result is the result after running.