在XML文件中如何做似SQL中的SUM()方法
Xml文件如下:
<?xml version= "1.0 " encoding= "utf-8 " ?>
<Table_Payment>
<payment ID= "1 " YEAR= "2006 " MONTH= "12 " DAY= "27 " TypeID= "2 " CONTENT= "衣服 " MONEY= "500.0000 "/>
<payment ID= "2 " YEAR= "2006 " MONTH= "12 " DAY= "27 " TypeID= "2 " CONTENT= "衣服 " MONEY= "500.0000 "/>
</Table_Payment>
在我想[MONEY]行似于sql中的按年月Sum(),不能,我采取的方法是先xml文件入DataSet,然后使用DataTable的Compute方法行sum累,搞了一上午法通,求能者指教。
附上我的C#代:
int intYear=2007;
int intMonth=1;
DataSet ds = new DataSet();
ds.ReadXml(System.Windows.Forms.Application.StartupPath+ @ "\Payment.xml ");
object ot = ds.Tables[0].Compute( "Sum(Convert(Double,[Money])) ", "Year = ' ' "+intYear+ " ' ' and Month= ' ' "+intMonth+ " ' ' ");
[解决办法]
晕,还没来过这..