Git Product home page Git Product logo

fluentxml's Introduction

Welcome to the FluentXML

This unit demonstrates how we can produce an XML document in Object Pascal (Delphi) with a simple way of using the fluent design pattern and is offered to community service for this purpose.

Uğur PARLAYAN

http://www.potansif.com

for example;
procedure TForm1.Button1Click(Sender: TObject);
var
 XML: TFluentXML;
begin
 try
   XML := New
         .Version(1.0)
         .Encoding(TEncoding.UTF8)
         .NameSpace('')
         .Add('Kitaplar'
             ,New
             .Add('Kitap', [ 'ID="1000"', 'Indirimli="Hayir"' ]
                 ,New
                 .Add('Adi'   , 'Mastering Delphi')
                 .Add('Fiyat' , 50)
                 .Add('Stok'  , 40)
                 .Add('Yazarlar'
                     ,New
                     .Add('Yazar', 'Marco CANTU')
                     .Add('Yazar', '<![CDATA[TEST]]>')
                     )
                 )
             .Add('Kitap', [ 'ID="1001"', 'Indirimli="Evet"' ]
                 ,New
                 .Add('Adi'   ,'PHP, MySQL ve Apache')
                 .Add('Fiyat' , 65)
                 .Add('Stok'  , 30)
                 .Add('Yazarlar'
                     ,New
                     .Add('Yazar', 'Julie C. MELONI')
                     )
                 )
             .Add('Kitap', [ 'ID="1002"', 'Indirimli="Evet"' ]
                 ,New
                 .Add('Adi'   ,'Delphi Cookbook')
                 .Add('Fiyat' , 35)
                 .Add('Stok'  , 300)
                 .Add('Yazarlar'
                     ,New
                     .Add('Yazar', 'Daniele TETİ')
                     )
                 )
             )
         ;
   Memo1.Text := XML.SaveToFile(‘C:\Temp\Demo.xml’).AsString;
 finally
   FreeAndNil(XML);
 end;
end;
And then the output produced is as follows;
<?xml version="1.0" encoding="UTF-8"?>
<Kitaplar>
	<Kitap ID="1000" Indirimli="Hayir">
		<Adi>Mastering Delphi</Adi>
		<Fiyat>50</Fiyat>
		<Stok>40</Stok>
		<Yazarlar>
			<Yazar>Marco CANTU</Yazar>
			<Yazar><![CDATA[TEST]]></Yazar>
		</Yazarlar>
	</Kitap>
	<Kitap ID="1001" Indirimli="Evet">
		<Adi>PHP, MySQL ve Apache</Adi>
		<Fiyat>65</Fiyat>
		<Stok>30</Stok>
		<Yazarlar>
			<Yazar>Julie C. MELONI</Yazar>
		</Yazarlar>
	</Kitap>
	<Kitap ID="1002" Indirimli="Evet">
		<Adi>Delphi Cookbook</Adi>
		<Fiyat>35</Fiyat>
		<Stok>300</Stok>
		<Yazarlar>
			<Yazar>Daniele TETİ</Yazar>
		</Yazarlar>
	</Kitap>
</Kitaplar>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.