datatable datasource(string xmlfile)
{dataset objds = new dataset();
//假设xml文件放在app_data目录下
objds.readxml(httpcontext.current.server.mappath("~/app_data/" + xmlfile));
return objds.tables[0];
}
string getfeildtext(datatable dt, string condition, string outputfieldtext)
{
string result = string.empty;
datarow[] row = dt.select(condition);
if (row.length > 0)
result = row[0][outputfieldtext].tostring();
return result;
}
//假设需求是:根据id找name
string getsexname(string id)
{
string condition = "id= '" + id+ "'";
return getfeildtext(datasource(), condition, "name");
}
首页 1 2 3 末页
时间: 2024-12-22 12:34:01