Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Catalog · How the catalog works
Anything · Lazarus or Delphi
Random projectRandom project

Delphi-XmlLite

. Delphi Header translation for Microsoft XmlLite. XmlLite is a native C++ implementation of .NET XmlReader+Writer for stream-based, forward-only XML parsing and creation. XmlLite.dll is required. It is included with all new versions of Windows, and service packs for old versions. XmlReader's pull-based interface is cleaner to use than SAX's event-based interface.

View on GitHub

Member rating

No ratings yet.

Sign in to rate this project.

README

Delphi-XmlLite

Header translation for Microsoft XmlLite

Note: This is a minimal translation, some parts were not implemented and most are untested.

Note: i only used it in Win32 projects, but Delphi/Win64 was independently tested at

Sample code taken from production. We use this to generate very large (>1GB) Xml files from an array of temporary files.

pascal
procedure AppendFile(const FileName: string; _IXMLWriter: IXMLWriter);
var
  _IXMLReader: IXMLReader;
  NodeType: Integer;
  LocalName: PWideChar;
  LocalNameLen: LongWord;
begin
  _IXMLReader := CreateXmlFileReader(FileName);
  while not _IXMLReader.IsEOF do
  begin
    _IXMLReader.GetLocalName(LocalName, LocalNameLen);
    if (LocalName = 'SecondLevelNodeName') then
      _IXMLWriter.WriteNode(_IXMLReader, True)
    else
      _IXMLReader.Read(NodeType);
  end;
end;
pascal
procedure CombineXmlFiles(const FileName: string; TempXmlFileArray: StringArray);
var
  _IXMLWriter : IXMLWriter;
  iCounter: Integer;
begin
  _IXMLWriter := CreateXmlFileWriter(FileName);
pascal
_IXMLWriter.SetProperty(XmlWriterProperty_Indent, LongInt(True));
pascal
_IXMLWriter.WriteStartDocument(XmlStandalone_Omit);
_IXMLWriter.WriteStartElement(nil, PWideChar('RootNodeName'), nil);
pascal
for iCounter := 0 to High(TempXmlFileArray) do
  AppendFile(TempXmlFileArray[iCounter], _IXMLWriter);
pascal
_IXMLWriter.WriteEndElement;
_IXMLWriter.WriteEndDocument;
_IXMLWriter.Flush;
pascal
end;