- Delphi Serialize Object To Xml Converter
- Delphi Serialize Object To Xml File
- C# Serialize Object
- C# Xml Serialize To File
We’ve got a huge data object structure, containing a lot of properties that are actually arrays. Now, we need to stream the data to an XML document. For that, we thought to use the NativeXML component to stream. It uses the same mechanism that’s also used for TComponent streaming. This works fairly nicely, except that it doesn’t stream. What's a good way to serialize a Delphi object tree to XML-using RTTI and not custom code? I would have loved to find that this feature is already built into Delphi, but it doesn't seem to be. I've found a few components (posted, below) that seem like they might perform this function. Xml Serialization - Basic Usage. This post relates to XmlSerial.pas which provides XML serialization and de-serialization using the new RTTI in Delphi 2010. This class has been built to serialize any public and published property or Field. This was done to mimic the behavior found in the.NET Xml Serialization with the goal of having a set of. What do I need to do in order to call the XML from my database. Saving Object As XML and showing Save Successful Message Hi, I have a Custom Object CustProfile. On Click of Save Button I am calling a method in the Business Layer and passing the CustProfile Object. This method uses the XML serializer to serialize the object and save it as XML.
NativeXml: A native Delphi XML parser and writer
Added: 28Sep2002
Updated: 09jun2015
Current version: 3.30
Open-Source version: 3.30
Languages: Delphi (5 - XE), Kylix, C++ Builder, Lazarus/FPC
The Serialize method is used to serialize an object to XML. This class has been built to serialize any public and published property or Field. This was done to mimic the behavior found in the.NET Xml Serialization with the goal of having a set of objects that can serialize in.NET using Delphi Prism and Win32 using Delphi 2010.
This software component contains a small-footprint Object Pascal (Delphi) XML implementation that allows to read and write XML documents. You basically only need one unit and you can simply add it to the 'uses' clause.
You can use this software to read XML documents from files, streams or strings. The load routine generates events that can be used to display load progress on the fly. You can also use it to create and save XML documents.
Open-Source!
NativeXml is currently open-sourced. See here:SimDesign's NativeXml forum
NativeXml.pas | This Pascal source file contains the complete XML functionality. Versions are included for Delphi 5 all the way thru Delphi XE! When you purchase, you are entitled to premium support through the forum and/or email. So please state your name and registration code in email. |
Additionals | Source files 'NativeXmlObjectStorage.pas' and 'NativeXmlAppend.pas', which provide object persistance.These Pascal source files contain the complete XML functionality. |
readme.txt | Information about the package. |
NativeXml.pdf | Document with description of object structure, properties, methods and types. It also contains 4 examples. |
Examples | These folders contain many example applications. The first one is a very simpe example showing the basics, the second shows a complete GUI application that can be used to browse XML Documents. The 3rd shows how to load/save records to/from XML, the 4th shows how to append XML nodes to the end of an XML file that remains on disk. Full source included in the examples! |
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.
Download
By downloading the package you must agree to the terms stated in the license file. Rightclick and use Save As...
Download | Full installer and uninstaller (916KB). The installer will put all files in the right place so that you can directly compile. |
Screenshot
This is a screenshot of the example application. The editor comes with full source, and shows how to use NativeXml to create XML content and how to use the parsed data. You can also directly use the editor to edit your XML files if you like, download it here.
Delphi Serialize Object To Xml Converter
Customers comments
Here are a few samples of what customers have to say about NativeXml:
This is the most functional and easy-to-use API for XML that I have come across for Delphi! Congratulations for all your efforts... Christian Boxer |
Your component is absolutely perfect! Milan Kunes - Milk Computers S.R.O. |
..really good work, nice to use and IMHO super-clean... Philipp Reif - S&U Software GmbH |
Just a quick note to say thank you for NativeXml: it is truly awesome! Keith Blows - ETA Audiovisual (Pty) Ltd |
Your NativeXml has been great for me. A huge time saver. Plus your support and responsiveness has been awesome. Ms. J. Lyle Martin - Integic Corp. USA |
Thanks and congratulations on a good product Paul Heffernan |
Thank you very much for your effort and extremely quick response! |
Amazing Component, Amazing Support. Using the NativeXml unit and the great support from SimDesign I was able to achieve in minutes what I had taken me hours with other XML components Phillip Herries |
Your unit works great. I've got almost the complete app converted to use it and everything seems to be working great. Fick van Deventer |
Related Links
Delphi Serialize Object To Xml File
VirtualTreeview component
This component implements a virtual tree that can be used to show information in tree-form. Written by Mike Lischke. This component comes as third party tool with Delphi7. For Delphi6 and before, please see above link.
C# Serialize Object
W3Schools XML tutorial
This is an ideal resource for learning the basics on XML.
C# Xml Serialize To File
W3C XML Specification
Here you can find the complete specification of the XML format.