1. Technology
Send to a Friend via Email

Reading and Manipulating XML files (RSS feeds) with Delphi


2 of 4

The TXMLDocument Component

To be able to display the latest headlines inside a Delphi project, you first need to download the XML file. Since this XML file is updated on a day by day basic (new entries added) you'll need code designed to save the contents of a specified URL to a file.

The TXMLDocument component

Once you have the XML file saved locally, we can "attack" it using Delphi. On the Internet page of the Component palette you'll find the TXMLDocument component. The main purpose of this component is to represent an XML document. TXMLDocument can read an existing XML document from a file, it can be associated with a well formatted string (in XML terms) that is the contents of an XML document, or it can create a new, empty XML document.

In general, here are the steps that describe how to use TXMLDocument:

  1. Add a TXMLDocument component to your form.
  2. If the XML document is stored in a file, set the FileName property to the name of that file.
  3. Set the Active property to True.
  4. The data XML represents is available as a hierarchy of nodes. Use methods designed to return and work with a node in an XML document (like ChildNodes.First).

©2014 About.com. All rights reserved.