-
Notifications
You must be signed in to change notification settings - Fork 49
/
OmniXMLDatabase.pas
581 lines (544 loc) · 23.5 KB
/
OmniXMLDatabase.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
(*:XML helper unit. Contains routines to copy data between XML and TDataSet.
@author Primoz Gabrijelcic
@desc <pre>
(c) 2003 Primoz Gabrijelcic
Free for personal and commercial use. No rights reserved.
Author : Primoz Gabrijelcic
Creation date : 2001-10-24
Last modification : 2003-03-31
Version : 1.03
</pre>*)(*
History:
1.04: 2022-05-18
- Fixed a bug in XMLNodeToDatasetRow and DatasetRowToXMLNode that
occurs when .Fields and .FieldDefs collections of TDataSet have
different member count and type. A typical case is when calculated
or lookup fields are created only in FieldDefs collection.
1.03: 2003-03-31
- Added methods DatasetToXMLFile, DatasetToXMLString, XMLFileToDataset,
XMLStringToDataset.
- Added parameter doNotExport to the Dataset*ToXML* methods containing
semicolon-delimited list of fields not to be exported.
- Added parameter doNotImport to the XML*ToDataset* methods containing
semicolon-delimited list of fields not to be imported.
- Added optional parameter outputFormat to the DatasetToXMLDocument
method.
- DatasetToXML wrapped into ds.DisableControls/ds.EnableControls. This
also applies to all DatasetToXML* methods. Initial position in the
dataset is now preserved.
- Fixed XMLNodeToDatasetRow to ignore case of the field name.
- Added testing for rootTag non-emptiness.
- Added <?xml version="1.0"?> to the exported XML document.
- Modified XMLToDataset method to skip non-ELEMENT_NODE nodes so one can
add comments to the XML file.
- Modified XML*ToDataset* methods to raise exception EOmniXMLDatabase
on errors.
- Modified XMLNodeToDatasetRow to raise exception EOmniXMLDatabase if
XML field doesn't exist in the table. This exception can be skipped
if option odbIgnoreMissingColumns is passed to the XML*ToDataset*
method.
- Modified XMLNodeToDatasetRow to raise exception EOmniXMLDatabase if
database column is not of a supported type. This exception can be
skipped if option odbIgnoreUnsupportedColumns is passed to the
XML*ToDataset* method.
- Modified DatasetRowToXMLNode to raise exception EOmniXMLDatabase if
database column is not of a supported type. This exception can be
skipped if option odbIgnoreUnsupportedColumns is passed to the
Dataset*ToXML* method.
1.02: 2002-12-09
- MSXML compatible (define USE_MSXML).
1.01a: 2002-11-05
- Modified function CleanupNodeName to use OmniXML.CharIs_Name.
1.01: 2002-10-22
- Updated to skip hidden fields (like DB_KEY returned from IBObjects
queries).
- Added numbers as valid tag characters (function CleanupNodeName).
1.0: 2001-10-24
- Created by extracting database-related functionality from unit GpXML.
*)
unit OmniXMLDatabase;
interface
{$I OmniXML.inc}
{$IFDEF OmniXML_HasZeroBasedStrings}
{$ZEROBASEDSTRINGS OFF}
{$ENDIF}
uses
{$IFDEF MSWINDOWS}
Windows,
{$ENDIF}
SysUtils, Classes, DB,
OmniXML
{$IFDEF USE_MSXML}, OmniXML_MSXML {$ENDIF USE_MSXML}
;
type
//:OmniXMLDatabase-specific exception.
EOmniXMLDatabase = Exception;
//:Import-export options.
TOmniXMLDatabaseOption = (odbIgnoreUnsupportedColumns, odbIgnoreMissingColumns);
//:Set of all import-export options.
TOmniXMLDatabaseOptions = set of TOmniXMLDatabaseOption;
{:Export currently selected dataset row to the XML node. Used internally in
the DatasetToXML.
}
procedure DatasetRowToXMLNode(ds: TDataSet; dsNode: IXMLNode;
const doNotExport: string = ''; options: TOmniXMLDatabaseOptions = []);
{:Export dataset to the XML node. Child nodes will be used to store the data.
Existing child nodes will be removed. To read data back into the dataset use
the XMLToDataset function.
}
procedure DatasetToXML(ds: TDataSet; parentNode: IXMLNode;
const doNotExport: string = ''; options: TOmniXMLDatabaseOptions = []);
{:Export dataset to the XML document, then take string representation of the
XML document and return it as as stream. Stream is emptied before it is
written to.
}
procedure DatasetToXMLDocument(ds: TDataSet; xmlDocument: TStream;
const rootTag: string; const doNotExport: string = '';
outputFormat: TOutputFormat = ofNone; options: TOmniXMLDatabaseOptions = []);
{:Export dataset to the XML document, then take string representation of the
XML document and save it into a file.
}
procedure DatasetToXMLFile(ds: TDataSet; const xmlFileName: string;
const rootTag: string; const doNotExport: string = '';
outputFormat: TOutputFormat = ofNone; options: TOmniXMLDatabaseOptions = []);
{:Export dataset to the XML document, then take string representation of the
XML document and return it as as string.
}
function DatasetToXMLString(ds: TDataSet; const rootTag: string;
const doNotExport: string = ''; outputFormat: TOutputFormat = ofNone;
options: TOmniXMLDatabaseOptions = []): string;
{:Append new dataset row, copy node data into equally-named fields, and post
the changes.
}
procedure XMLNodeToDatasetRow(dsNode: IXMLNode; ds: TDataSet;
const doNotImport: string = ''; options: TOmniXMLDatabaseOptions = []);
{:Import data created with DatasetToXML from the XML node to the dataset.
Existing dataset content won't be touched.
}
procedure XMLToDataset(parentNode: IXMLNode; ds: TDataSet;
const doNotImport: string = ''; options: TOmniXMLDatabaseOptions = []);
{:Create XML document from the textual representation stored in the stream,
then copy its contents into the dataset. Dataset will be emptied before the
import. XML document must be created with the DatasetToXML* call.
Before reading, stream's position is reset to 0 and all data from the stream
is read.
}
procedure XMLDocumentToDataset(xmlDocument: TStream; ds: TDataSet;
const doNotImport: string = ''; options: TOmniXMLDatabaseOptions = []);
{:Create XML document from the textual representation stored in the file,
then copy its contents into the dataset. Dataset will be emptied before the
import. XML document must be created with the DatasetToXML* call.
}
procedure XMLFileToDataset(const xmlFileName: string; ds: TDataSet;
const doNotImport: string = ''; options: TOmniXMLDatabaseOptions = []);
{:Create XML document from the textual representation stored in the string,
then copy its contents into the dataset. Dataset will be emptied before the
import. XML document must be created with the DatasetToXMLD* call.
}
procedure XMLStringToDataset(const xmlString: string; ds: TDataSet;
const doNotImport: string = ''; options: TOmniXMLDatabaseOptions = []);
implementation
uses
OmniXMLUtils;
const
//:Node name to be used in TDataSet <-> XML conversion.
CXMLDatasetRows = 'ROW'; // don't change!
//:Atribute that specifies whether field is empty (NULL).
CXMLFieldIsEmpty = 'isEmpty'; // don't change!
{:Clean XML node name to only contain valid characters. Unicode is politely
ignored.
}
function CleanupNodeName(nodeName: string): string;
var
iNodeName: integer;
begin
SetLength(Result, Length(nodeName)); // best guess;
for iNodeName := 1 to Length(nodeName) do begin
if CharIs_Name(WideChar(nodeName[iNodeName]), false) then
Result[iNodeName] := nodeName[iNodeName]
else
Result[iNodeName] := '_';
end; //for iNodeName
if (Length(nodeName) > 0) and (not CharIs_Name(WideChar(Result[1]), true)) then
Result[1] := 'z';
end; { CleanupNodeName }
{:@param ds Dataset row to be exported.
@param dsNode XML node to take data from the dataset row. Existing
content will be removed.
@param doNotExport Semicolon-delimited list of fields that should not be
exported. No extraneous whitespace should be used.
@param options Export options.
@since 2001-09-09
}
procedure DatasetRowToXMLNode(ds: TDataSet; dsNode: IXMLNode;
const doNotExport: string; options: TOmniXMLDatabaseOptions);
var
field : TField;
fieldClass : TFieldClass;
fieldElement: IXMLElement;
iField : integer;
memStr : TMemoryStream;
nodeName : string;
notExport : string;
begin
if doNotExport = '' then
notExport := ''
else
notExport := ';' + doNotExport + ';';
DeleteAllChildren(dsNode);
for iField := 0 to ds.FieldDefs.Count-1 do begin
if faHiddenCol in ds.FieldDefs[iField].Attributes then
continue;
field := ds.FieldByName(ds.FieldDefs[iField].Name);
fieldClass := ds.FieldDefs[iField].FieldClass;
if (notExport = '') or (Pos(';'+field.FieldName+';', notExport) = 0) then begin
nodeName := CleanupNodeName(field.FieldName);
fieldElement := dsNode.OwnerDocument.CreateElement(nodeName);
dsNode.AppendChild(fieldElement);
if field.IsNull then
fieldElement.SetAttribute(CXMLFieldIsEmpty, XMLBoolToStr(true))
else begin
if fieldClass.InheritsFrom(TStringField) then
fieldElement.Text := field.AsString
// check for TAutoIncField must be before TIntegerField
else if fieldClass.InheritsFrom(TAutoIncField) then
// skipped
else if fieldClass.InheritsFrom(TIntegerField) then
fieldElement.Text := XMLIntToStr(field.AsInteger)
else if fieldClass.InheritsFrom(TLargeIntField) then
fieldElement.Text := XMLInt64ToStr((field as TLargeintField).AsLargeInt)
else if fieldClass.InheritsFrom(TBCDField) or
fieldClass.InheritsFrom(TCurrencyField) then
fieldElement.Text := XMLRealToStr(field.AsCurrency)
else if fieldClass.InheritsFrom(TFloatField) then
fieldElement.Text := XMLRealToStr(field.AsFloat)
else if fieldClass.InheritsFrom(TDateField) then
fieldElement.Text := XMLDateToStr(field.AsDateTime)
else if fieldClass.InheritsFrom(TTimeField) then
fieldElement.Text := XMLTimeToStr(field.AsDateTime)
else if fieldClass.InheritsFrom(TDateTimeField) then
fieldElement.Text := XMLDateTimeToStr(field.AsDateTime)
else if fieldClass.InheritsFrom(TBooleanField) then
fieldElement.Text := XMLBoolToStr(field.AsBoolean)
else if fieldClass.InheritsFrom(TBlobField) then
begin
memStr := TMemoryStream.Create;
try
(field as TBLOBField).SaveToStream(memStr);
memStr.Position := 0;
SetNodeTextBinary(dsNode, nodeName, memStr);
finally FreeAndNil(memStr); end;
end
else if fieldClass.InheritsFrom(TBytesField) then
begin
memStr := TMemoryStream.Create;
try
memStr.SetSize(field.DataSize);
(field as TBytesField).GetData(memStr.Memory);
SetNodeTextBinary(dsNode, nodeName, memStr);
finally FreeAndNil(memStr); end;
end
else begin
if not (odbIgnoreUnsupportedColumns in options) then
raise EOmniXMLDatabase.CreateFmt('Unsupported column type in column %s', [field.FieldName]);
end;
end;
end; //if notExport ...
end; //for
end; { DatasetRowToXMLNode }
{:@param ds Dataset to be exported.
@param parentNode Node containing exported data, stored in CXMLDatasetRows
children.
@param doNotExport Semicolon-delimited list of fields that should not be
exported. No extraneous whitespace should be used.
@param options Export options.
@since 2001-09-09
}
procedure DatasetToXML(ds: TDataSet; parentNode: IXMLNode;
const doNotExport: string; options: TOmniXMLDatabaseOptions);
var
myNode : IXMLNode;
startPos: TBookmark;
begin
DeleteAllChildren(parentNode, CXMLDatasetRows);
ds.DisableControls;
try
startPos := ds.GetBookmark;
try
ds.First;
while not ds.Eof do begin
myNode := parentNode.OwnerDocument.CreateElement(CXMLDatasetRows);
parentNode.AppendChild(myNode);
DatasetRowToXMLNode(ds, myNode, doNotExport, options);
ds.Next;
end; //while
finally
try ds.GotoBookmark(startPos); except end;
ds.FreeBookmark(startPos);
end;
finally ds.EnableControls; end;
end; { DatasetToXML }
{:@param ds Dataset to be exported.
@param xmlDocument Textual representation of the XML document holding data
from the ds, stored in the stream.
@param doNotExport Semicolon-delimited list of fields that should not be
exported. No extraneous whitespace should be used.
@param outputFormat XML document formatting.
@param options Export options.
@since 2001-09-09
}
procedure DatasetToXMLDocument(ds: TDataSet; xmlDocument: TStream;
const rootTag: string; const doNotExport: string;
outputFormat: TOutputFormat; options: TOmniXMLDatabaseOptions);
var
xml: IXMLDocument;
begin
if Trim(rootTag) = '' then
raise Exception.Create('DatasetToXMLDocument: rootTag must not be empty');
xml := CreateXMLDoc;
xml.AppendChild(xml.CreateProcessingInstruction('xml', 'version="1.0"'));
xml.AppendChild(xml.CreateElement(rootTag));
DatasetToXML(ds, xml.DocumentElement, doNotExport, options);
xmlDocument.Position := 0;
xmlDocument.Size := 0;
XMLSaveToStream(xml, xmlDocument, outputFormat);
end; { DatasetToXMLDocument }
{:@param ds Dataset to be exported.
@param xmlFileName Name of the file to receive XML document.
@param doNotExport Semicolon-delimited list of fields that should not be
exported. No extraneous whitespace should be used.
@param outputFormat XML document formatting.
@param options Export options.
@since 2003-03-28
}
procedure DatasetToXMLFile(ds: TDataSet; const xmlFileName: string;
const rootTag: string; const doNotExport: string;
outputFormat: TOutputFormat; options: TOmniXMLDatabaseOptions);
var
fs: TFileStream;
begin
if Trim(rootTag) = '' then
raise Exception.Create('DatasetToXMLFile: rootTag must not be empty');
fs := TFileStream.Create(xmlFileName, fmCreate);
try
DatasetToXMLDocument(ds, fs, rootTag, doNotExport, outputFormat, options);
finally FreeAndNil(fs); end;
end; { DatasetToXMLFile }
{:@param ds Dataset to be exported.
@param doNotExport Semicolon-delimited list of fields that should not be
exported. No extraneous whitespace should be used.
@param outputFormat XML document formatting.
@param options Export options.
@returns Textual representation of the XML document holding data from the ds.
@since 2003-03-28
}
function DatasetToXMLString(ds: TDataSet; const rootTag: string;
const doNotExport: string; outputFormat: TOutputFormat;
options: TOmniXMLDatabaseOptions): string;
var
ss: TStringStream;
begin
if Trim(rootTag) = '' then
raise Exception.Create('DatasetToXMLString: rootTag must not be empty');
ss := TStringStream.Create('');
try
DatasetToXMLDocument(ds, ss, rootTag, doNotExport, outputFormat, options);
Result := ss.DataString;
finally FreeAndNil(ss); end;
end; { DatasetToXMLString }
{:@param dsNode Node holding the data to be exported to the dataset.
@param ds Dataset to take data from the dsNode.
@param doNotImport Semicolon-delimited list of fields that should not be
imported. No extraneous whitespace should be used.
@param options Import options.
@since 2001-09-09
}
procedure XMLNodeToDatasetRow(dsNode: IXMLNode; ds: TDataSet;
const doNotImport: string; options: TOmniXMLDatabaseOptions);
var
field : TField;
fieldClass : TClass;
fieldElement: IXMLElement;
fieldNode : IXMLNode;
memStr : TMemoryStream;
myNode : IXMLNode;
myNodes : IXMLNodeList;
nodeData : WideString;
nodeName : string;
notImport : string;
function FindField(nodeName: string): TField;
var
iField: integer;
begin
for iField := 0 to ds.Fields.Count-1 do begin
Result := ds.Fields[iField];
if AnsiSameText(CleanupNodeName(Result.FieldName), nodeName) then
Exit;
end; //for
Result := nil;
end; { FindField }
begin { XMLNodeToDatasetRow }
if doNotImport = '' then
notImport := ''
else
notImport := ';' + doNotImport + ';';
ds.Append;
myNodes := dsNode.ChildNodes;
myNodes.Reset;
repeat
myNode := myNodes.NextNode;
if assigned(myNode) and (myNode.NodeType = ELEMENT_NODE) then begin
nodeName := myNode.NodeName;
field := FindField(nodeName);
if (notImport = '') or (Pos(';'+field.FieldName+';', notImport) = 0) then begin
if not assigned(field) then begin
if not (odbIgnoreMissingColumns in options) then
raise EOmniXMLDatabase.CreateFmt('Field %s does not exist in the table', [nodeName]);
end
else begin
fieldNode := dsNode.SelectSingleNode(nodeName);
field.Clear;
if assigned(fieldNode) and
Supports(fieldNode, IXMLElement, fieldElement) and
(fieldElement.GetAttribute(CXMLFieldIsEmpty) <> XMLBoolToStr(true)) then
begin
nodeData := fieldNode.Text;
fieldClass := ds.Fields[field.Index].ClassType;
if fieldClass.InheritsFrom(TStringField) then
field.AsString := nodeData
// check for TAutoIncField must be before TIntegerField
else if fieldClass.InheritsFrom(TAutoIncField) then
// skipped
else if fieldClass.InheritsFrom(TIntegerField) then
field.AsInteger := XMLStrToIntDef(nodeData, 0)
else if fieldClass.InheritsFrom(TLargeIntField) then
(field as TLargeintField).AsLargeInt := XMLStrToInt64Def(nodeData, 0)
else if fieldClass.InheritsFrom(TBCDField) or
fieldClass.InheritsFrom(TCurrencyField) then
field.AsCurrency := XMLStrToRealDef(nodeData, 0)
else if fieldClass.InheritsFrom(TFloatField) then
field.AsFloat := XMLStrToRealDef(nodeData, 0)
else if fieldClass.InheritsFrom(TDateField) then
field.AsDateTime := XMLStrToDateDef(nodeData, 0)
else if fieldClass.InheritsFrom(TTimeField) then
field.AsDateTime := XMLStrToTimeDef(nodeData, 0)
else if fieldClass.InheritsFrom(TDateTimeField) then
field.AsDateTime := XMLStrToDateTimeDef(nodeData, 0)
else if fieldClass.InheritsFrom(TBooleanField) then
field.AsBoolean := XMLStrToBoolDef(nodeData, false)
else if fieldClass.InheritsFrom(TBlobField) then
begin
memStr := TMemoryStream.Create;
try
GetNodeTextBinary(dsNode, nodeName, memStr);
memStr.Position := 0;
(field as TBLOBField).LoadFromStream(memStr);
finally FreeAndNil(memStr); end;
end
else if fieldClass.InheritsFrom(TBytesField) then
begin
memStr := TMemoryStream.Create;
try
GetNodeTextBinary(dsNode, nodeName, memStr);
memStr.Position := 0;
field.Size := memStr.Size;
(field as TBytesField).SetData(memStr.Memory);
finally FreeAndNil(memStr); end;
end
else begin
if not (odbIgnoreUnsupportedColumns in options) then
raise EOmniXMLDatabase.CreateFmt('Unsupported column type in column %s', [field.FieldName]);
end;
end;
end;
end; //if notImport ...
end;
until not assigned(myNode);
ds.Post;
end; { XMLNodeToDatasetRow }
{:@param parentNode Node that holds CXMLDatasetRows children that will be
exported to the dataset.
@param ds Dataset to take data from the parentNode.
@param doNotImport Semicolon-delimited list of fields that should not be
imported. No extraneous whitespace should be used.
@param options Import options.
@since 2001-09-09
}
procedure XMLToDataset(parentNode: IXMLNode; ds: TDataSet;
const doNotImport: string; options: TOmniXMLDatabaseOptions);
var
myNode : IXMLNode;
myNodes: IXMLNodeList;
begin
if assigned(parentNode) then begin
myNodes := parentNode.SelectNodes(CXMLDatasetRows);
myNodes.Reset;
ds.DisableControls;
try
repeat
myNode := myNodes.NextNode;
if assigned(myNode) and (myNode.NodeType = ELEMENT_NODE) then
XMLNodeToDatasetRow(myNode, ds, doNotImport, options);
until not assigned(myNode);
finally ds.EnableControls; end;
end;
end; { XMLToDataset }
{:@param xmlDocument Textual representation of the XML document, stored in the
stream.
@param ds Dataset to take data from the XML document.
@param doNotImport Semicolon-delimited list of fields that should not be
imported. No extraneous whitespace should be used.
@param options Import options.
@since 2001-09-09
}
procedure XMLDocumentToDataset(xmlDocument: TStream; ds: TDataSet;
const doNotImport: string; options: TOmniXMLDatabaseOptions);
var
xml: IXMLDocument;
begin
xml := CreateXMLDoc;
xmlDocument.Position := 0;
if XMLLoadFromStream(xml, xmlDocument) then begin
if assigned(xml.DocumentElement) then
XMLToDataset(xml.DocumentElement, ds, doNotImport, options);
end
else
raise EOmniXMLDatabase.CreateFmt(
'Failed to parse XML document. Error occured at character %d line %d. Reason: %s',
[xml.ParseError.LinePos, xml.ParseError.LinePos, xml.ParseError.Reason]);
end; { XMLDocumentToDataset }
{:@param xmlFileName Name of the file containing XML document.
@param ds Dataset to take data from the XML document.
@param doNotImport Semicolon-delimited list of fields that should not be
imported. No extraneous whitespace should be used.
@param options Import options.
@since 2003-03-28
}
procedure XMLFileToDataset(const xmlFileName: string; ds: TDataSet;
const doNotImport: string; options: TOmniXMLDatabaseOptions);
var
fs: TFileStream;
begin
fs := TFileStream.Create(xmlFileName, fmOpenRead);
try
XMLDocumentToDataset(fs, ds, doNotImport, options);
finally FreeAndNil(fs); end;
end; { XMLFileToDataset }
{:@param xmlString String containing XML document.
@param ds Dataset to take data from the XML document.
@param doNotImport Semicolon-delimited list of fields that should not be
imported. No extraneous whitespace should be used.
@param options Import options.
@since 2003-03-28
}
procedure XMLStringToDataset(const xmlString: string; ds: TDataSet;
const doNotImport: string; options: TOmniXMLDatabaseOptions);
var
ss: TStringStream;
begin
ss := TStringStream.Create(xmlString);
try
XMLDocumentToDataset(ss, ds, doNotImport, options);
finally FreeAndNil(ss); end;
end; { XMLStringToDataset }
end.