TXMLDocumentLoadFromStream (Object Pascal)

From Appmethod Code Examples
Jump to: navigation, search

Description

The following example uses the LoadFromStream function.

Code

procedure Test_LoadFromStream;
const
  CFilename = 'file.xml'; { Should exist. }
var
  LDocument: IXMLDocument;
  LFileStream: TFileStream;
begin
  LDocument := TXMLDocument.Create(nil);

  LFileStream := TFileStream.Create(CFilename, fmOpenRead);

  { Use default encoding type (xetUnknown). }
  LDocument.LoadFromStream(LFileStream);

  { Display document element local name. }
  if LDocument.DocumentElement <> nil then
    Writeln(LDocument.DocumentElement.LocalName);

  LFileStream.Free;
end;

Uses