1. Technology

Reading and Manipulating XML files (RSS feeds) with Delphi

By

4 of 4

Full Source Code
Reading and Manipulating XML files (RSS feeds) with Delphi
I suppose the code is more or less easy to understand:
  1. Make sure FileName property of the TXMLDocument points to our XML file.
  2. Set Active to True
  3. Find the first <item> ("meat") node
  4. Iterate through all the <item> nodes and grab the information they cary.
  5. Add each <item> node's value to ListView

Maybe only the next line can be confusing: StartItemNode := XMLDoc.DocumentElement.ChildNodes.First.ChildNodes.FindNode('item') ;

The DocumentElement property of the XMLDoc provides access to the root node of the document. This root node is the <rss> element. Next, ChildNodes.First returns the only child node to the <rss> element, which is the <channel> node. Now, ChildNodes.FindNode('item') finds the first "meat" node. Once we have the first <item> node we simply iterate through all the "meat" nodes in the document. The NextSibling method returns the next child of a node’s parent.

That's it. Make sure you download the full source. And of course, feel free and encouraged to post any comments to this article on our Delphi Programming Forum.

  1. About.com
  2. Technology
  3. Delphi
  4. Coding Internet / Network
  5. Reading and Manipulating XML files (RSS feeds) with Delphi

©2014 About.com. All rights reserved.