XML foundation DataSet loading XML data file

xiaoxiao2021-03-31  214

When developing a system, there is often a DESCRIPTION to get its Description by CODE, such as acquiring error messages by the error number.

These error messages can be stored in the XML data file and read with a DataSet object.

Here is the read function:

Public String getError (int erroorid) {// When you are displayed, you can put a text of the error number in an XML // file. This is a general method that supports multi-language. // This example from one The data is removed in the XML file and get an error description of the specified ID number.

String filename; DATAROW [] DR; // file path can also configure filename = this.request.physicalApplicationPath "/ERRORINFO.XML" in the web.config file; // Create a DataSet object Dataset DS = New Dataset ("ErrorInfo" ); // read XML file DS.ReadXML (filename); // to find DR = DS.TABLES [0] .Select ("code =" errorid.tostring ()); if (Dr.Length == 1 ) {RETURN DR [0] ["description"]. Tostring ();} else {return ";}}

Below is an XML file example:

200 Success 700 password is incorrect 800 Account Invalid

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

New Post(0)