Delphi操作XML的技巧
Delphi操作XML是很方便的,主要有两种方法;
1.用TClientDataSet操作XML;TClientDataSet是个好东西,用它操作XML是很简单的事,不过缺点是只能操作固定格式的 XML,它适合操作表结构的数据,如果你需要把数据表导出成XML那用TClientDataSet是个好主意,比如下面是一个数据集导出成XML的方 法:
procedure ExportToXML(SrcDataSet:TDataSet;const XMLFileName:String);
var tmpCds:TClientDataSet;
i:integer;
NewField:TFieldDef;
begin
SrcDataSet.DisableControls;
tmpCds:=TClientDataSet.Create(nil);
try
for i:=0 to SrcDataSet.FieldCount-1 do
begin
NewField:=tmpCds.FieldDefs.AddFieldDef;
NewField.Name:=SrcDataSet.Fields[i].FieldName;
NewField.DataType:=SrcDataSet.fields[i].DataType;
NewField.Size:=SrcDataSet.Fields[i].Size;
end;
tmpCds.CreateDataSet;
if tmpCds.Active then tmpCds.LogChanges:=False;
SrcDataSet.First;
while not SrcDataSet.Eof do
begin
tmpCds.Append;
for i:=0 to SrcDataSet.FieldCount-1 do
tmpCds.FieldByName(SrcDataSet.Fields[i].FieldName).Value:=SrcDataSet.Fields[i].Value;
tmpCds.Post;
SrcDataSet.Next;
end;
tmpCds.SaveToFile(XMLFileName);
finally
SrcDataSet.EnableControls;
tmpCds.Free;
end;
end;
2.还有一种方法就是用TXMLDocument了,TXMLDocument很灵活,因此操作起来有点麻烦,特别是XML树很深的时候。不过 Delphi给我们提供了更方便的方法,使我们更加简单的操作XML,这个方法就是XML Data Binding向导,XML Data Binding向导会把XML的节点映射成对象,从而使我们更方便的操作它们。下面是一个XML Da
相关文档:
Caused by: java.sql.SQLException: ORA-00918: column ambiguously defined
Caused by: com.ibatis.common.jdbc.exception.NestedSQLException:
--- The error occurred in com/ibatis/jpetstore/persistence/sqlmapdao/sql/Item.xml.
--- The error occurred while applying a parameter map.&nbs ......
var createXML = function (str) {
if (typeof DOMParser !== "undefined") {
return (new DOMParser()).parsefromString(str, "application/xml");
}else if (typeof ActiveXObject != "undefined") {
if (typeof arguments.callee.activeXString !== "string" ......
DELPHI中操作ACCESS数据库(建立.mdb文件,压缩数据库)
以下代码在WIN2K,D6,MDAC2.6下测试通过,
编译好的程序在WIN98第二版无ACCESS环境下运行成功.
//声明连接字符串
Const
SConnectionString
= 'Provider=M ......
最近需要将Magento(国外比较出名的开源PHP+MySQL电子商务网站)与一个ERP进行整合,就需要调用Magento的Webservice。
Magento提供2套api。
注:如果需要同构调用需要使用第1个wsdl,如异构程序调用需使用第2个wsdl。
1.http://xxx.xxxxxxx.xxx/magento/api/soap/?wsdl
2.http://xxx.xxxxxxx.xxx/magento/api/v2_soap/?ws ......