1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
|
# xml example
If you like directly working with XML, here's an example of how to for this:
```ts
const posts = [
{
title: 'Launching SSH during early boot with mkinitfs',
url: 'https://estrogen.zone/~mem/blog/1768406136-alpine-ssh-early-initfs-disk-decryption/',
blurb: 'Replacing the early init with our own script to launch SSH, killing it in early userspace, and allowing remote disk decryption in the mean time',
author: '7222e800',
guid: 'https://estrogen.zone/~mem/blog/1768406136',
published: new Date('2026-01-14T15:53:57Z').toUTCString()
}
];
const doc = new XMLDocumentRoot().child(
new XMLDeclaration().version().encoding(),
new XMLRootElement("rss")
.attribute("version", "2.0")
.xmlns("content", "http://purl.org/rss/1.0/modules/content/")
.child(
new XMLElement('channel')
.child(
new XMLElement('title').child(new XMLText('Latest blog posts for 7222e800')),
new XMLElement('link').child(new XMLText('https://estrogen.zone/~mem/blog/')),
new XMLElement('description').child(new XMLText('Some Description')),
new XMLElement('pubDate').child(new XMLText(new Date().toUTCString())),
...posts.map(post => new XMLElement('item').child(
new XMLElement('title').child(new XMLText(post.title)),
new XMLElement('link').child(new XMLText(post.url)),
new XMLElement('description').child(new XMLText(post.blurb)),
new XMLElement('author').child(new XMLText(post.author)),
new XMLElement('guid').child(new XMLText(post.guid)),
new XMLElement('published').child(new XMLText(post.published)),
))
)
)
);
console.log(
util.inspect(
doc,
{ compact: false, colors: true, breakLength: 80, depth: 90 }, true
)
);
console.log(doc.toString());
```
as of writing, will output this internal state:
```log
XMLDocumentRoot {
attributes: Map(0) {},
children: [
XMLDeclaration {
attributes: Map(2) {
'version' => '1.0',
'encoding' => 'UTF-8'
},
children: [],
tagType: '#declaration'
},
XMLRootElement {
attributes: Map(2) {
'version' => '2.0',
'xmlns:content' => 'http://purl.org/rss/1.0/modules/content/'
},
children: [
XMLElement {
attributes: Map(0) {},
children: [
XMLElement {
attributes: Map(0) {},
children: [
XMLText {
tagType: '#text',
text: 'Latest blog posts for 7222e800'
}
],
tagType: '#element',
tagName: 'title'
},
XMLElement {
attributes: Map(0) {},
children: [
XMLText {
tagType: '#text',
text: 'https://estrogen.zone/~mem/blog/'
}
],
tagType: '#element',
tagName: 'link'
},
XMLElement {
attributes: Map(0) {},
children: [
XMLText {
tagType: '#text',
text: 'Some Description'
}
],
tagType: '#element',
tagName: 'description'
},
XMLElement {
attributes: Map(0) {},
children: [
XMLText {
tagType: '#text',
text: 'Mon, 26 Jan 2026 03:34:31 GMT'
}
],
tagType: '#element',
tagName: 'pubDate'
},
XMLElement {
attributes: Map(0) {},
children: [
XMLElement {
attributes: Map(0) {},
children: [
XMLText {
tagType: '#text',
text: 'Launching SSH during early boot with mkinitfs'
}
],
tagType: '#element',
tagName: 'title'
},
XMLElement {
attributes: Map(0) {},
children: [
XMLText {
tagType: '#text',
text: 'https://estrogen.zone/~mem/blog/1768406136-alpine-ssh-early-initfs-disk-decryption/'
}
],
tagType: '#element',
tagName: 'link'
},
XMLElement {
attributes: Map(0) {},
children: [
XMLText {
tagType: '#text',
text: 'Replacing the early init with our own script to launch SSH, killing it in early userspace, and allowing remote disk decryption in the mean time'
}
],
tagType: '#element',
tagName: 'description'
},
XMLElement {
attributes: Map(0) {},
children: [
XMLText {
tagType: '#text',
text: '7222e800'
}
],
tagType: '#element',
tagName: 'author'
},
XMLElement {
attributes: Map(0) {},
children: [
XMLText {
tagType: '#text',
text: 'https://estrogen.zone/~mem/blog/1768406136'
}
],
tagType: '#element',
tagName: 'guid'
},
XMLElement {
attributes: Map(0) {},
children: [
XMLText {
tagType: '#text',
text: 'Wed, 14 Jan 2026 15:53:57 GMT'
}
],
tagType: '#element',
tagName: 'published'
}
],
tagType: '#element',
tagName: 'item'
}
],
tagType: '#element',
tagName: 'channel'
}
],
tagType: '#element',
tagName: 'rss'
}
],
tagType: '#document'
}
```
and this RSS:
```xml
<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
<title>
Latest blog posts for 7222e800
</title>
<link>
https://estrogen.zone/~mem/blog/
</link>
<description>
Some Description
</description>
<pubDate>
Mon, 26 Jan 2026 03:34:31 GMT
</pubDate>
<item>
<title>
Launching SSH during early boot with mkinitfs
</title>
<link>
https://estrogen.zone/~mem/blog/1768406136-alpine-ssh-early-initfs-disk-decryption/
</link>
<description>
Replacing the early init with our own script to launch SSH, killing it in early userspace, and allowing remote disk decryption in the mean time
</description>
<author>
7222e800
</author>
<guid>
https://estrogen.zone/~mem/blog/1768406136
</guid>
<published>
Wed, 14 Jan 2026 15:53:57 GMT
</published>
</item>
</channel>
</rss>
```
|