xml| Load | data
When developing a system, there is often code to get its description, such as error messages from error numbers.
These error messages can be stored in an XML data file and read through a DataSet object.
Here is the Read function:
public string geterror (int errorid)
{
When you make an error display, you can put the text description corresponding to the error number in an XML
File. This is a common way to support multiple languages.
This example extracts the data from an XML file and gets the error description for the specified ID number.
string filename;
Datarow[] Dr;
The file path can also be configured in the Web.config file
Filename=this. Request.physicalapplicationpath + "/errorinfo.xml";
Creating a DataSet Object
DataSet ds=new DataSet ("ErrorInfo");
reading XML files
Ds. READXML (filename);
To find
Dr=ds. Tables[0]. Select ("code=" + errorid.tostring ());
if (Dr. Length==1)
{
return dr[0]["Description"]. ToString ();
}
Else
{
Return "";
}
}
The following is an example of an XML file:
<ErrorInfo>
<ErrorItem>
<Code>200</Code>
<Description> Success </Description>
</ErrorItem>
<ErrorItem>
<Code>700</Code>
<Description> Wrong Password </Description>
</ErrorItem>
<ErrorItem>
<Code>800</Code>
<Description> Account Invalid </Description>
</ErrorItem>
</ErrorInfo>