Convert XML files containing data in the eCH-0252 standard format to easy-to-use dataframes using the eCHparser package.
You can install the development version of eCHparser from GitHub with:
# install.packages("devtools")
devtools::install_github("statistikZH/eCHparser")
The eCH-0252 standard is used to feed voting data from cantonal IT systems to the voteInfo API, which then uses the data to display live vote counting information, for example via the voteInfo App or the Results and Information Plattform of the Canton of Zurich. This data will be publicly available in this format starting in 2025. However, example files are already available in this package (see example bellow).
The function parse_eCH_0252()
allows users to transform these XML
files to easy-to-use dataframes.
library(eCHparser)
# list all sample files
example_files <- system.file("extdata", package = "eCHparser") |>
list.files()
# pick a random sample file
file <- sample(seq_along(example_files), 1)
# define filepath to sample file
filepath <- system.file("extdata", testfiles[file], package = "eCHparser")
# parse file, using only federal and cantonal votes
vote_df <- parse_eCH_0252(filepath, doi = c("CH", "CT"))