-
Notifications
You must be signed in to change notification settings - Fork 3
/
make_xml.R
27 lines (22 loc) · 830 Bytes
/
make_xml.R
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
library(xml2)
# Read Hyndsight xml
rjh <- read_xml(here::here("_site/hyndsight/index.xml")) |>
as_list()
# Fix meta data
rjh[[1]][[1]][1]$title[[1]] <- "Rob J Hyndman"
rjh[[1]][[1]][2]$link[[1]] <- "https://robjhyndman.com"
attr(rjh[[1]][[1]][3]$link, "href") <- "https://robjhyndman.com/index.xml"
rjh[[1]][[1]][4]$description[[1]] <- "Recent content by Rob J Hyndman"
# Add Publications xml
publications <- read_xml(here::here("_site/publications/index.xml")) |>
xml_child() |>
as_list()
rjh[[1]][[1]] <- append(rjh[[1]][[1]], publications[7:26])
# Add Seminars xml
seminars <- read_xml(here::here("_site/seminars/index.xml")) |>
xml_child() |>
as_list()
rjh[[1]][[1]] <- append(rjh[[1]][[1]], seminars[7:26])
# Write out new combined xml
as_xml_document(rjh) |>
write_xml(file = here::here("_site/index.xml"))