Error when parse an url of XML

When I use xmlTreeParse function to parse an url

fileUrl <- "http://www.w3schools.com/xml/simple.xml" 
doc <- xmlTreeParse(fileUrl,useInternal=TRUE) 

and it response an error message

Unknown IO error failed to load external entity "http://www.w3schools.com/xml/simple.xml" 

the url is good , I can download the file using browser

BUT
If I download the file first
the parse function seems to work good

> download.file("http://www.w3schools.com/xml/simple.xml",destfile = "simple.xml")
试开URL’http://www.w3schools.com/xml/simple.xml'
Content type 'text/xml' length 1119 bytes
==================================================
downloaded 1119 bytes

> doc <- xmlTreeParse("simple.xml",encoding = "ASCII", useInternalNodes = T  )
rn <- xmlRoot(doc)
rn2 <- xmlToDataFrame(rn)
> rn2
                         name price                                                                         description
1             Belgian Waffles $5.95                   Two of our famous Belgian Waffles with plenty of real maple syrup
2  Strawberry Belgian Waffles $7.95                   Light Belgian waffles covered with strawberries and whipped cream
3 Berry-Berry Belgian Waffles $8.95 Light Belgian waffles covered with an assortment of fresh berries and whipped cream
4                French Toast $4.50                                 Thick slices made from our homemade sourdough bread
5         Homestyle Breakfast $6.95                 Two eggs, bacon or sausage, toast, and our ever-popular hash browns
  calories
1      650
2      900
3      900
4      600
5      950

Can anyone tell my what this message mean and how to deal with it ?
thanks!

documentation for xmlTreeParse : xmlTreeParse function - RDocumentation

try the isURL=TRUE flag

I tried , but it doesn't work as usual
Same Error message I got
thank you anyway! :grin:

Problem seems to be solved with httr package

library("httr")
library("XML")
> fileUrl <- "http://www.w3schools.com/xml/simple.xml"
> doc <- xmlParse(rawToChar(GET(fileUrl)$content))
> a <- xmlToDataFrame(doc)
> a
                         name price                                                                         description
1             Belgian Waffles $5.95                   Two of our famous Belgian Waffles with plenty of real maple syrup
2  Strawberry Belgian Waffles $7.95                   Light Belgian waffles covered with strawberries and whipped cream
3 Berry-Berry Belgian Waffles $8.95 Light Belgian waffles covered with an assortment of fresh berries and whipped cream
4                French Toast $4.50                                 Thick slices made from our homemade sourdough bread
5         Homestyle Breakfast $6.95                 Two eggs, bacon or sausage, toast, and our ever-popular hash browns
  calories
1      650
2      900
3      900
4      600
5      950

It seems something wrong with the loading resources step that build in XML package.

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

If you have a query related to it or one of the replies, start a new topic and refer back with a link.