[ASPASP.NET] The simplest XML creation, write operation

xiaoxiao2021-03-06  100

// Built a new empty XML document

XmlTextWriter Objxml = New XMLTextWriter (Server.MAppath ("Text.xml"), NULL);

/ / Format Output XML document

Objxml.formatting = formatting.indented;

Objxml.indentation = 4;

// Write XML document tag

Objxml.writestartDocument ();

// Write XML document comment

Objxml.writeComment ("Created Using AN XML" Context.TimeStamp);

// write root elements

Objxml.writestartElement ("BookList");

// Write an element

Objxml.writestartElement ("Book");

// Write properties

Objxml.writeAttributeString ("Category", "Technology");

// Write attribute value

Objxml.writeAttributeString ("PageCount", "1234");

// write sub-elements and text values

Objxml.writeElementstring ("Title", "Professional Video Recorder Programming");

// write sub-elements and text values

Objxml.writeElementstring ("ReleaseDate", "02/02/2002");

// Write an element

Objxml.writestartElement ("AuthorList");

// write sub-elements and text values

Objxml.writeElementString ("Author", "FRAMCESCA UNIX");

// write sub-elements and text values

Objxml.writeElementstring ("Author", "William Soft");

// Close the child elements, elements, root elements

Objxml.writeEndelement ();

Objxml.writeEndelement ();

Objxml.writeEndelement ();

//clear cache

Objxml.flush ();

// Close the object

Objxml.close ();

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

New Post(0)