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 code>
700 code>
800 code>