unit concfg;
interface
uses
Windows, Messages, SysUtils, Classes,IcXMLStrings, IcXMLParser;
type
TConcfg = class
applicationname: string;
provider: string;
connectTimeout: string;
datasource: string;
initialCatalog: string;
userid: string;
version: string;
password: String;
function GetConnectString: string;
constructor Create(AFilename: string);
end;
implementation
constructor TConcfg.Create(AFilename: string);
var
text: TIcXMLText;
ele: TIcXMLElement;
par: TIcXMLParser;
doc : TIcXMLDocument;
begin
par := TIcXMLParser.Create(nil);
doc := TIcXMLDocument.Create;
//doc.SetEncoding(''UTF-8'');
try
par.Parse(AFilename,doc);
ele := doc.GetDocumentElement;
version := ele.GetAttribute(''version'');
ele := ele.GetFirstChild;
while ele <> nil do
begin
if (ele.TagName = ''ApplicationName'') then
if ele.HasCharData then
begin
text := ele.GetFirstCharData;
applicationname := trim(text.GetValue);
end;
if (ele.TagName = ''Provider'') then
if ele.HasCharData then
begin
text := ele.GetFirstCharData;
provider := trim(text.GetValue);
end;
if (ele.TagName = ''DataSource'') then
if ele.HasCharData then
begin
text := ele.GetFirstCharData;
datasource := trim(text.GetValue);
end;
if (ele.TagName = ''InitialCatalog'') then
if ele.HasCharData then
begin
text := ele.GetFirstCharData;
InitialCatalog := trim(text.GetValue);
&nbs