NativeXml
Features
Read
XML directly from string, stream or file with fast parser (1Mb/sec on 1.5GHz P3), writes to string, stream and file even faster.
Import of all common tags, including comments, CDATA,
XML declarations and stylesheets.
Load from streaming media is supported; you can set up events to work with the node data while it comes in. See example 1. No need to keep the whole
XML document in memory! Works well for huge documents. This is the
SAX-like approach.
Save to file, string or stream in readable, preserve or compact format. Readable format will add linefeeds and indents to make the file readable in a text editor. Compact format sticks to the
Xml specification and adds minimal control characters. Preserve format keeps the markup of the document exactly as it was.
Directly add blobs or streams in the
XML file, they will be encoded as Binhex or Base64 (but you don't have to worry about that).
Many native Delphi types can be stored directly to the nodes, making this code very suitable to use while writing storage methods. Store and load boolean, single, double, word, integer, string, TFont, TColor, TPen, TBrush, TDateTime. You don't have to worry about escaping the strings; this is done automatically.
Loads and saves
ANSI, UTF-8 as well as
Unicode (UTF-16) documents and implements proper conversion warnings. Recognises streams even without byte order marks. NativeXml works internally with UTF8 encoded strings to preserve extended characters, and supports widestrings.
Unique feature: Store, read and create any TPersistent object to/from
XML directly (see Example5). This is done by iterating through all of the objects' published properties by use of
RTTI (runtime type information). This feature is only available for D5 and up.
New! Now you can use the binary format of NativeXml. This avoids the expensive parsing process to get the textual
xml data into the document (
DOM). And even better, the binary file size is much smaller, ~50% of file size with uncompressed binary files, and ~15% of the file size in
zlib-compressed files. And you can use AES encryption to keep your sensitive files safe from prying eyes.
The interface is the same whether textual
xml or binary
xml files are used, so you can work with binary files for speed and size purposes, then always send them to the public as normal
xml files.