//定义
XmlDataSet: TClientDataSet;
XmlTrans: TXMLTransform;
//数据读取
XmlTrans:=TXMLTransform.Create(self);
XmlTrans.SourceXmlFile:=ExtractFilePath(Application.ExeName)+'report.xml';
XmlTrans.TransformationFile:=ExtractFilePath(Application.ExeName)+'report.xtr';//用xml mapper工具根据xml文件生成的文件
XmlDataSet:=TClientDataSet.Create(self);
XmlDataSet.XMLData:=XmlTrans.Data;
XmlDataSet.IndexDefs.Add('noasc','no',[ixPrimary]);
XmlDataSet.IndexDefs.Add('lastpricedesc','lastprice',[ixDescending]);
//Filter过滤
XmlDataSet.Filter:='bargainflag=1 and lasttype=0';
XmlDataSet.Filtered:=true;
if self.RzRadioButtonLastprice.Checked then
XmlDataSet.IndexName:='lastpricedesc'
else
XmlDataSet.IndexName:='noasc';
//取记录值
XmlDataSet.RecNo:=frxUserDataSet4.RecNo+1;
Value:=XmlDataSet.FieldByName(FieldName).AsString;
XmlDataSet: TClientDataSet;
XmlTrans: TXMLTransform;
//数据读取
XmlTrans:=TXMLTransform.Create(self);
XmlTrans.SourceXmlFile:=ExtractFilePath(Application.ExeName)+'report.xml';
XmlTrans.TransformationFile:=ExtractFilePath(Application.ExeName)+'report.xtr';//用xml mapper工具根据xml文件生成的文件
XmlDataSet:=TClientDataSet.Create(self);
XmlDataSet.XMLData:=XmlTrans.Data;
XmlDataSet.IndexDefs.Add('noasc','no',[ixPrimary]);
XmlDataSet.IndexDefs.Add('lastpricedesc','lastprice',[ixDescending]);
//Filter过滤
XmlDataSet.Filter:='bargainflag=1 and lasttype=0';
XmlDataSet.Filtered:=true;
if self.RzRadioButtonLastprice.Checked then
XmlDataSet.IndexName:='lastpricedesc'
else
XmlDataSet.IndexName:='noasc';
//取记录值
XmlDataSet.RecNo:=frxUserDataSet4.RecNo+1;
Value:=XmlDataSet.FieldByName(FieldName).AsString;