There are lot of possibilities if you’re in need to parse or write XML files:

Now here comes another one: VerySimpleXML – a lightweight, one-unit XML reader/writer in under 500 600 lines of code. Use it for small well-formed XML files (like configuration files, etc.).

Download verysimplexml-v1.1.zip (7kb)

Download verysimplexml-v1.0.zip (7kb)

What’s new:

v1.1 – 2012/05/01

changed class name to reflect unit naming (class is now called

TXmlVerySimple instead TVerySimpleXml)

– it uses TStreamReader to read line by line instead of reading the

whole file at once (this allows parsing of big xml files with little

additional memory)

– automatically escapes/unescapes not allowed chars (>, <, “, &), thus

removes the most-hated “- escaping introduced in v1.0

Some usage examples:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 uses Xml . VerySimple ; var Xml : TXmlVerySimple ; Node , Child : TXmlNode ; begin Xml : = TXmlVerySimple . 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 ;

VerySimpleXML supports just a subset of the XML specification

load and save from stream or file

nodes, childs and attributes

UTF-8 and ANSI encoding

compact output by setting Xml.Ident := ”;

method chaining

“>” and “>” inside text and attribute values when wrapped in quotation marks (XML-spec requires you to transform them into < etc.) now automatically escaped with v1.1

It does NOT support:

CDATA, comments, etc…

Example XML-file:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 <!--?xml version="1.0" encoding="utf-8" ?--> Gambardella , Matthew Ralls , Kim A former architect battles corporate zombies no - muerto zombies Corets , Eva The collapse of a society