Questions tagged [xml2]

xml2 is an R package which makes it easy to work with HTML and XML from R.

xml2 is an R package which makes it easy to work with HTML and XML from R. It is part of the tidyverse.

It leverages the C library libxml2 and the API is somewhat inspired by jQuery.

For more info, checkout the GitHub repo for the package.

295 questions
10
votes
2 answers

How to configure the curl package in R with default web proxy settings?

I'm using R in a commercial environment where external connectivity all goes via a web proxy, so we need to specify the proxy server address and ensure we connect to it with Windows authentication. I already have code that will configure the RCurl…
djb72
  • 101
  • 1
  • 4
10
votes
4 answers

Python/R: generate dataframe from XML when not all nodes contain all variables?

Consider the following XML example library(xml2) myxml <- read_xml(' John tennis golf python Robert
ℕʘʘḆḽḘ
  • 18,566
  • 34
  • 128
  • 235
8
votes
4 answers

How to save and read output of read_html as an RDS file?

Objects can be saved and read like so # Save as file saveRDS(iris, "mydata.RDS") # Read back in readRDS("mydata.RDS") But this doesn't seem to work for objects made with xml2::read_html() Example library(rvest) someobject <-…
stevec
  • 41,291
  • 27
  • 223
  • 311
8
votes
1 answer

xml_find_all function from xml2 package (R) does not find relevant nodes

I am using the xml2 package in R to access xml data, and found that it behaves different on different xml_documents. On this pet example library(xml2) doc <- read_xml( "
dertomtom
  • 179
  • 2
  • 6
8
votes
1 answer

Parsing XML in R: Incorrect namespaces

I have a bunch of XML files and an R script that reads their content into a data frame. However, I got now files which I wanted to parse as usual, but there is something in their namespace definition that doesn't allow me to pick their values…
nikopartanen
  • 577
  • 8
  • 15
7
votes
1 answer

In R, use rvest and xml2 to extract JSON object from a