Simple XML manipulation: XML file creation
Copy the following code into the button event to produce the Pos.xml file in the corresponding physical path after the compilation is executed
XmlTextWriter xtw = new XmlTextWriter (Request.physicalapplicationpath + "Pos.xml", System.Text.Encoding.UTF8);
Xtw. formatting = formatting.indented;
Xtw. WriteStartDocument (FALSE);
Results:
Xtw. WriteComment ("Pos infomation");
Document Comment Results:
Xtw. WriteStartElement ("Info");
XML Root node Result:
Xtw. WriteStartElement ("Zc", null);
XML element 1 Result:
Xtw. WriteElementString ("Kmdm", "0301");
XML element 1 Key value result: 0301
Xtw. WriteElementString ("SCBJ", "1");
XML element 1 Key value Result: 1
Xtw. WriteElementString ("Zy", "100");
XML element 1 Key value result: 100
Xtw. WriteEndElement ();
XML element 1 End result:
Xtw. Flush ();
Xtw. WriteStartElement ("Posinfo", null);
XML element 2 Result:
Xtw. WriteAttributeString ("Kpid", "030100111");
Xtw. WriteAttributeString ("Posx", "289");
Xtw. WriteAttributeString ("Posy", "47");
XML element 2 Property Result:
Xtw. WriteEndElement ();
XML element 2 End result:
Xtw. WriteEndElement ();
XML Root End Result:
Xtw. Flush ();
Xtw. Close ()//Free resources
Note: Results are run results
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.