Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/viniciussanchez/xml-builder
XML Builder for Delphi and Lazarus
https://github.com/viniciussanchez/xml-builder
builder delphi fpc lazarus xml
Last synced: about 2 months ago
JSON representation
XML Builder for Delphi and Lazarus
- Host: GitHub
- URL: https://github.com/viniciussanchez/xml-builder
- Owner: viniciussanchez
- License: mit
- Created: 2022-02-09T13:45:51.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2022-02-10T18:02:44.000Z (almost 3 years ago)
- Last Synced: 2024-11-07T08:51:25.307Z (3 months ago)
- Topics: builder, delphi, fpc, lazarus, xml
- Language: Pascal
- Homepage:
- Size: 21.5 KB
- Stars: 57
- Watchers: 7
- Forks: 14
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# XML Builder
## ⚙️ Installation
Installation is done using the [`boss install`](https://github.com/HashLoad/boss) command line:
``` sh
boss install viniciussanchez/xml-builder
```## ⚙️ Manual Installation for Delphi
If you choose to install manually, simply add the following folders to your project, in *Project > Options > Resource Compiler > Directories and Conditionals > Include file search path*
```
../xml-builder/src
```## ⚡️ Quickstart
```pascal
uses Xml.Builder;var
LDeveloperNode, LProjectsNode: IXmlNode;
begin
LProjectsNode := TXmlNode.New('projects')
.AddElement('Horse', 'yes')
.AddElement('Boss', 'yes')
.AddElement('RESTRequest4Delphi', 'yes')
.AddElement('DataSet-Serialize', 'yes')
.AddElement('BCrypt', 'yes');LDeveloperNode := TXmlNode.New('developer')
.AddAttribute('mvp', 'true')
.AddElement('firstName', 'Vinicius')
.AddElement('lastName', 'Sanchez')
.AddElement('age')
.AddNode(LProjectsNode);TXmlBuilder.New
.AddNode(LDeveloperNode)
.Xml;
end;// Another way to implement:
begin
TXmlBuilder.New
.AddNode(TXmlNode.New('developer')
.AddAttribute('mvp', 'true')
.AddElement('firstName', 'Vinicius')
.AddElement('lastName', 'Sanchez')
.AddElement('age')
.AddNode(TXmlNode.New('projects')
.AddElement('Horse', 'yes')
.AddElement('Boss', 'yes')
.AddElement('RESTRequest4Delphi', 'yes')
.AddElement('DataSet-Serialize', 'yes')
.AddElement('BCrypt', 'yes')))
.Xml;
end;
```
Result:
```xmlVinicius
Sanchez
yes
yes
yes
yes
yes
```
You can also save the file to disk:
```pascal
TXmlBuilder.New.SaveToFile('C:\sample.xml');
```## ⚡️ DataSet Adapter
```pascal
uses Xml.Builder;begin
mtDeveloper.Append;
mtDeveloperfirstName.AsString := 'Vinicius';
mtDeveloperlastName.AsString := 'Sanchez';
mtDevelopermvp.AsBoolean := True;
mtDeveloper.Post;
mmXml.Lines.Text := TXmlBuilder.Adapter(mtDeveloper).Xml;
end;
```
Result:
```xmlVinicius
Sanchez
True```
## ⚠️ License
`XML Builder` is free and open-source software licensed under the [MIT License](https://github.com/viniciussanchez/xml-builder/blob/master/LICENSE).