Debian Codegraph @

src/compatibility/delphi-only/xmlread.pas

raw
1 {
2 Copyright 2019-2019 Michalis Kamburelis.
3
4 This file is part of "Castle Game Engine".
5
6 "Castle Game Engine" is free software; see the file COPYING.txt,
7 included in this distribution, for details about the copyright.
8
9 "Castle Game Engine" is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12
13 ----------------------------------------------------------------------------
14 }
15
16 { Delphi XML reading routines.
17 This unit is compatible with a subset of FPC XMLRead unit. }
18 unit XMLRead;
19
20 {$I castleconf.inc}
21
22 interface
23
24 uses SysUtils, Classes, XMLDoc,
25 DOM;
26
27 type
28 EXMLReadError = class(Exception);
29
30 procedure ReadXMLFile(out Doc: TXMLDocument; const Stream: TStream); overload;
31 procedure ReadXMLFile(out Doc: TXMLDocument; const Stream: TStream; const ABaseURI: String); overload;
32
33 implementation
34
35
36 procedure ReadXMLFile(out Doc: TXMLDocument; const Stream: TStream);
37 begin
38 Doc := TXMLDocument.Create;
39 try
40 Doc.LoadFromStream(Stream);
41 except
42 on E: Exception do
43 raise EXMLReadError.Create('Error when reading XML: ' + E.Message);
44 end;
45 end;
46
47 // TODO: BaseURI
48 procedure ReadXMLFile(out Doc: TXMLDocument; const Stream: TStream; const ABaseURI: String); overload;
49 begin
50 Doc := TXMLDocument.Create;
51 try
52 Doc.LoadFromStream(Stream);
53 except
54 on E: Exception do
55 raise EXMLReadError.Create('Error when reading XML: ' + E.Message);
56 end;
57 end;
58
59
60 end.