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?

Extensible Markup Language is a universal language for data on the Web. XML gives developers the power to deliver structured data from a 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 evaluates 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 content on a webpage, XML defines and communicates data, it describes the type of content. Hence, "extensible," because it is not a fixed format like HTML.

Think of each XML file as a self-contained database. Tags -- the markup in an XML document, offset by angle brackets -- delineate the records and fields. The text between the tags is the data. Users 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, you should know how to work with XML documents.

XML with Delphi

For more information about pairing Delphi and XML, read:

Learn 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
Explore how to read and manipulate XML documents with Delphi using the TXMLDocument component. See how to extract the most current "In The Spotlight" blog entries (RSS feed) from the About Delphi Programming content environment, as an example.

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

If you need to work with dynamically created TXMLDocument component, you might get access violations after you try to free the object. This article offers a solution to this error message.

Delphi's implementation of the TXMLDocument component, which uses Microsoft XML parser by default, does not provide a way to add a node of the "ntDocType" (TNodeType type). This article provides a solution to this problem.

XML in Detail

Peruse the full XML standard and syntax at the W3C site.
A community website where XML developers share resources and solutions. The site includes timely news, opinions, features and tutorials.