Simple XML Operation: XML file creation

xiaoxiao2021-03-06  53

[阿 好 快 入 入 系 ---- XML]

Simple XML Operation: XML file creation

Copy the following code to the button event to compile execution, generate the POS.xml file XMLTextWriter XTW = New 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 Note Result:

Xtw.writeStartElement ("info"); // XML root node results:

XTW.WriteStartElement ("ZC", NULL);

// XML element 1 Result:

Xtw.writeElementstring ("KMDM", "0301");

// XML element 1 key value:

0301

Xtw.writeElementstring ("scbj", "1");

// XML element 1 key value:

1

Xtw.writeElementstring ("ZY", "100");

// XML element 1 key value:

100

Xtw.writeEndelement ();

// XML element 1 ends the result:

Xtw.flush ();

Xtw.WriteStartElement ("Posinfo", NULL;

// XML element 2 results:

XTW.WRITEATTRIBUTESTRING ("KPID", "030100111");

Xtw.writeAttributeString ("POSX", "289");

XTW.WRITEATTRIBUTESTRING ("Posy", "47");

// XML element 2 attribute results:

Xtw.writeEndelement ();

// XML element 2 ends the result:

Xtw.writeEndelement ();

// XML root end Result:

Xtw.flush (); xtw.close (); // Release Resource Note: The result is running result

转载请注明原文地址:https://www.9cbs.com/read-117029.html

New Post(0)