-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of github.com:viniciussanchez/xml-builder
- Loading branch information
Showing
1 changed file
with
83 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,83 @@ | ||
# xml-builder | ||
# 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: | ||
```xml | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<developer mvp="true"> | ||
<firstName>Vinicius</firstName> | ||
<lastName>Sanchez</lastName> | ||
<age /> | ||
<projects> | ||
<Boss>yes</Boss> | ||
<DataSet-Serialize>yes</DataSet-Serialize> | ||
<RESTRequest4Delphi>yes</RESTRequest4Delphi> | ||
<BCrypt>yes</BCrypt> | ||
<Horse>yes</Horse> | ||
</projects> | ||
</developer> | ||
``` | ||
You can also save the file to disk: | ||
```pascal | ||
TXmlBuilder.New.SaveToFile('C:\sample.xml'); | ||
``` | ||
|
||
## ⚠️ License | ||
|
||
`XML Builder` is free and open-source software licensed under the [MIT License](https://github.com/viniciussanchez/xml-builder/blob/master/LICENSE). |