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 componentOnce 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:
- Add a TXMLDocument component to your form.
- If the XML document is stored in a file, set the FileName property to the name of that file.
- Set the Active property to True.
- 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).