Dismiss Notice

REGISTRATION IS AFTER ADMIN ACTIVATION

DONATIONS WITH PAYPAL CLICK TO BUTTON

3 MONTHS VIP - 10$; 6 MONTHS VIP - 20$; 1 YEAR VIP - 30$; 2 YEARS VIP - 50$; GOLD USER FOR LIFE VIP - 150$

DONATIONS WITH Bitcoin Address:3NRs3CK3fhXifrNYxHEZKpETDd9vNLMsMD

Dismiss Notice
The registration is approved by the Administrator. It takes about 1 day to approve your registration
Dismiss Notice
For open hidden message no need write thanks, thank etc. Enough is click to like button on right side of thread.

VerySimpleXML – a lightweight Delphi XML reader and writer

Discussion in 'Delphi Components' started by N0body, May 23, 2014.

  1. N0body
    Online

    N0bodyN0body is a Verified Member DelphiFan Administrator Staff Member DF Staff

    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.).

    hanged 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:

    Code:
    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:

    Code:
    <?xml version="1.0" encoding="utf-8" ?>
    <catalog>
      <book id="bk101">
        <author>Gambardella, Matthew</author>
        <title/>
        <keywords />
      </book>
      <book id=bk102 lang="en">
        <author>Ralls, Kim</author>
        <title>Midnight Rain</title>
        <description>A former architect battles corporate zombies</description>
        <keywords>
          <keyword lang="es">no-muerto</keyword>
          <keyword lang=en>zombies</keyword>
        </keywords>
      </book>
      <book id="bk103">
        <author rate=">5">Corets, Eva</author>
        <title>Maeve Ascendant</title>
        <description>The collapse of a <nanotechnology> society</description>
      </book>
    </catalog>
    Download HERE
     
  2. mopkrayz
    Offline

    mopkrayz DF Junior

    RE:

    is this better than TXMLDocument ?
     
  3. N0body
    Online

    N0bodyN0body is a Verified Member DelphiFan Administrator Staff Member DF Staff

    i dont know i dont try this include have just one pas file for use.
    If you wish you can try this and share result with us :D
     

Share This Page

Laws
Our website, law, laws, copyright and aims to be respectful of individual rights. Our site, as defined in the law of 5651 serves as a provider of space. According to the law, contrary to the law of site management has no obligation to monitor content. Therefore, our site has adopted the principle of fit and remove. Works are subject to copyright laws and is shared in a manner that violated their legal rights, or professional associations, rights holders who, adsdelphi@gmail.com I can reach us at e-mail address. Complaints considered to be infringing on the examination of the content will be removed from our site.
Donate Help To Us and Be VIP
DONATIONS WITH PAYPAL CLICK TO BUTTON
6 MONTHS VIP - 20$; 1 YEAR VIP - 30$; 2 YEARS VIP - 50$; GOLD USER FOR LIFE VIP - 150$
Social Block