Parsing XML data

I hav installed xml2 package and RCurl package and loaded the librariries
library(xml2)
library(RCurl)
library(xmlparsedata)
url<-getURL("Empire Burlesque")

xmldoc<-xml_parse_data(url)
Error in !nrow(pd) : invalid argument type
mldoc<-xmlparsedata(url)
Error in xmlparsedata(url) : could not find function "xmlparsedata"

This Error I am getting in R studio for both xmlparsedata and xml_parse_data

what are you trying to do ?
the library(xmlparsedata) has description xmlparsedata: Parse Data of 'R' Code as an 'XML' Tree
So I don't think its relevant for you to try xml files on its functions. Rather it would be for if you were passing R scripts (like for linting etc.)
you can read the xml with read_xml from xml2 ,and find elements in it etc

in short I think you dont need xmlparsedata most likely

Hello Sir How can i parse data from url catalog.xml
u mean to say to read xml data
using read_xml(url)
that will work so that all elemnts of xml can be read
Thanks for ur reply awaiting for more clarity

library(xml2)
library(RCurl)
library(tidyverse)

url <- getURL("https://www.w3schools.com/xml/cd_catalog.xml")

xmldoc <- xml2::read_xml(url)

xlist <- xml2::as_list(xmldoc)

# investigate
str(xlist, max.level = 1)
str(head(xlist[[1]]))

(result_df <- as_tibble(map_dfr(
  xlist[[1]],
  ~ set_names(
    x = as.data.frame(.),
    names(.)
  )
)))

# # A tibble: 26 x 6
# TITLE                    ARTIST          COUNTRY COMPANY        PRICE YEAR 
# <fct>                    <fct>           <fct>   <fct>          <fct> <fct>
# 1 Empire Burlesque         Bob Dylan       USA     Columbia       10.90 1985 
# 2 Hide your heart          Bonnie Tyler    UK      CBS Records    9.90  1988 
# 3 Greatest Hits            Dolly Parton    USA     RCA            9.90  1982 
# 4 Still got the blues      Gary Moore      UK      Virgin records 10.20 1990 
# 5 Eros                     Eros Ramazzotti EU      BMG            9.90  1997 
# 6 One night only           Bee Gees        UK      Polydor        10.90 1998 
# 7 Sylvias Mother           Dr.Hook         UK      CBS            8.10  1973 
# 8 Maggie May               Rod Stewart     UK      Pickwick       8.50  1990 
# 9 Romanza                  Andrea Bocelli  EU      Polydor        10.80 1996 
# 10 When a man loves a woman Percy Sledge    USA     Atlantic       8.70  1987 
# # ... with 16 more rows

Thank You So much nirgra sir

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.