Skip to content

Commit 71a9f60

Browse files
Merge branch 'main' of github.com:viniciussanchez/xml-builder
2 parents 30c447c + 4bd2959 commit 71a9f60

File tree

1 file changed

+83
-1
lines changed

1 file changed

+83
-1
lines changed

README.md

Lines changed: 83 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,83 @@
1-
# xml-builder
1+
# XML Builder
2+
3+
## ⚙️ Installation
4+
Installation is done using the [`boss install`](https://github.com/HashLoad/boss) command line:
5+
``` sh
6+
boss install viniciussanchez/xml-builder
7+
```
8+
9+
## ⚙️ Manual Installation for Delphi
10+
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*
11+
```
12+
../xml-builder/src
13+
```
14+
15+
## ⚡️ Quickstart
16+
17+
```pascal
18+
uses Xml.Builder;
19+
20+
var
21+
LDeveloperNode, LProjectsNode: IXmlNode;
22+
begin
23+
LProjectsNode := TXmlNode.New('projects')
24+
.AddElement('Horse', 'yes')
25+
.AddElement('Boss', 'yes')
26+
.AddElement('RESTRequest4Delphi', 'yes')
27+
.AddElement('DataSet-Serialize', 'yes')
28+
.AddElement('BCrypt', 'yes');
29+
30+
LDeveloperNode := TXmlNode.New('developer')
31+
.AddAttribute('mvp', 'true')
32+
.AddElement('firstName', 'Vinicius')
33+
.AddElement('lastName', 'Sanchez')
34+
.AddElement('age')
35+
.AddNode(LProjectsNode);
36+
37+
TXmlBuilder.New
38+
.AddNode(LDeveloperNode)
39+
.Xml;
40+
end;
41+
42+
// Another way to implement:
43+
44+
begin
45+
TXmlBuilder.New
46+
.AddNode(TXmlNode.New('developer')
47+
.AddAttribute('mvp', 'true')
48+
.AddElement('firstName', 'Vinicius')
49+
.AddElement('lastName', 'Sanchez')
50+
.AddElement('age')
51+
.AddNode(TXmlNode.New('projects')
52+
.AddElement('Horse', 'yes')
53+
.AddElement('Boss', 'yes')
54+
.AddElement('RESTRequest4Delphi', 'yes')
55+
.AddElement('DataSet-Serialize', 'yes')
56+
.AddElement('BCrypt', 'yes')))
57+
.Xml;
58+
end;
59+
```
60+
Result:
61+
```xml
62+
<?xml version="1.0" encoding="UTF-8"?>
63+
<developer mvp="true">
64+
<firstName>Vinicius</firstName>
65+
<lastName>Sanchez</lastName>
66+
<age />
67+
<projects>
68+
<Boss>yes</Boss>
69+
<DataSet-Serialize>yes</DataSet-Serialize>
70+
<RESTRequest4Delphi>yes</RESTRequest4Delphi>
71+
<BCrypt>yes</BCrypt>
72+
<Horse>yes</Horse>
73+
</projects>
74+
</developer>
75+
```
76+
You can also save the file to disk:
77+
```pascal
78+
TXmlBuilder.New.SaveToFile('C:\sample.xml');
79+
```
80+
81+
## ⚠️ License
82+
83+
`XML Builder` is free and open-source software licensed under the [MIT License](https://github.com/viniciussanchez/xml-builder/blob/master/LICENSE).

0 commit comments

Comments
 (0)