Skip to content

Methods to convert a XML string into a JSON string, and to covert a JSON string into an XML string.

Notifications You must be signed in to change notification settings

johndharrison/JSON2XML

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JSON2XML

USAGE

Using JSON2XML is straightforward. There are two functions for conversion: json2XML and xml2JSON.

xml2JSON

require(JSON2XML)
fileURL <-  "http://api.sportsdatallc.org/nfl-t1/2013/REG/1/statistics.xml?api_key=4dhyq3f3rfkp2cbm4yqbcuag"
xData <- readLines(fileURL)
jData <- xml2JSON(paste(xData, collapse='')) # convert to JSON
out <- RJSONIO::fromJSON(jData)
do.call(rbind.data.frame, out$games$game[[1]]$team[[1]][[c('defense', 'player')]])

json2XML

require(JSON2XML)
jsonString <- RJSONIO::toJSON(list(a=1, r = list(b = 2:3, c= 'd')), collapse = '')
xData <- json2XML(jsonString)
XML::xmlParse(json2XML(jsonString))

Getting started

To install JSON2XML you will need the devtools package. If necessary (install.packages("devtools")) and run:

devtools::install_github("johndharrison/JSON2XML")

About

Methods to convert a XML string into a JSON string, and to covert a JSON string into an XML string.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages