Lightweight XML Parser

To those of you who read and write basic XML, the thought of using the DOM or some other monstrosity may make you think twice about using XML. No more excuses as I just came across a post by Dennis Spreen who has announced his Delphi based verysimpleXML library. This is perfect for reading and writing XML based configuration files or even larger files that use just the basic XML elements.
The following is an example from his web site.

uses Xml.VerySimple;
 
var
  Xml: TVerySimpleXML;
  Node, Child: TXmlNode;
begin
  Xml := TVerySimpleXml.Create;
  Xml.LoadFromFile('example.xml');
  Xml.Root.Find('book', 'id', 'bk102').Find('author').Text := 'Dein, Carol';
  Node := Xml.Root.AddChild('book');
  Child := Node.AddChild('author');
  Child.Text := 'Barger, Al';
  Child.Attribute['type'] := 'topseller';
  Node.AddChild('title').SetAttribute('lang', 'en').SetText('A big View');
  Xml.SaveToFile('output.xml');
  Xml.Free;
end;
This entry was posted in Delphi, Programming, Software. Bookmark the permalink.

Leave a Reply

Your email address will not be published.