1. Technology

Creating, Parsing and Manipulating XML Documents with Delphi

Delphi and the Extensible Markup Language


Businesswoman looking at computer, through window
Noel Hendrickson/Photographer's Choice RF/Getty Images

What is XML?

XML is the 'Extensible Markup Language', universal language for data on the Web. XML gives developers the power to deliver structured data from a wide variety of applications to the desktop for local computation and presentation. XML is also an ideal format for server-to-server transfer of structured data. Using an XML parser, software is able to walk through the hierarchy of the document extracting the structure of the document, its content, or both. XML is in no way limited to Internet use. In fact, XML's main strength - organizing information - makes it perfect for exchanging data between different systems.

XML looks much like HTML. However, whereas HTML describes the layout of a page (for data displaying purposes) XML is concerned with defining and describing data, it describes the type of content. Hence, 'extensible' because it is not a fixed format like HTML.

We can also think of each XML file as a mini database. Tag, or markups (the text surrounded by angle brackets) in an XML document delineate the records and fields. The text between the tags is the data. We perform operations like retrieving, updating, and inserting data with XML using a parser and a set of objects exposed by the parser.

As a Delphi programmer, what you need to know is how to use XML. Therefore, in this article I'll be presenting several ways in which XML can be integrated into your Delphi applications.

Doing XML with Delphi

Delphi provides a wrapper component designed to read, create and parse XML documents: TXMLDocument.

Here's a list of XML related articles and tips:

Exporting TreeView to XML. Constructing a TreeView from XML
Here's how to store TTreeView component items to XML (preserving the Text and other properties of a tree node) and how to populate a TreeView from an XML file.

Simple Reading and manipulating RSS feeds files with Delphi
Learn how to read and manipulate XML documents with Delphi using the TXMLDocument component. Let's see how to extract the most current "In The Spotlight" blog entries (RSS feed) from the About Delphi Programming (this site).

Database table to XML and back
Creating XML files from Paradox (or any DB) tables using Delphi. See how to export the data from a table to a XML file and how to import that data back to the table.

How to create, use and free TXMLDocument dynamically (without an AV)
Delphi tip: If you need to work with dynamically created TXMLDocument component, you might be getting access violations once you try to Free the object. Here's what to do ...

How to Create the !DocType and ?XML Elements using TXmlDocument
Delphi's implementation of the TXMLDocument component, which basically uses Microsoft XML parser by default, does not provide a way to add a node of the "ntDocType" (TNodeType type). Here's how to solve this problem.

XML Topics - not Delphi related

XML standard and syntax at the W3C site

Where the general XML community shares resources and solutions, features timely news, opinions, features, and tutorials.

About Delphi Programming

©2014 About.com. All rights reserved.