Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# Error in readering XML from URL

Tags:

c#

xml

I have an XML reader but I receive an error when I'm trying to read the XML from an URL (external source).

This is the code I have ATM:

XmlReader xmlReader = XmlReader.Create("http://dl.bukkit.org/api/1.0/downloads/projects/craftbukkit/view/build-1330/");
        while (xmlReader.Read())
        {

        }

Very simple code, but it returns an error which says:

Data at the root level is invalid. Line 1, position 1.

Any idea?
I can't edit the XML, because it's not mine.

Thanks in advance!

like image 610
Yuki Kutsuya Avatar asked Aug 10 '26 09:08

Yuki Kutsuya


1 Answers

If you use Fiddler to analyze the response returned by the sever, you'll see, that you get JSON instead of XML. You can add a parameter to the URL to get XML:

http://dl.bukkit.org/api/1.0/downloads/projects/craftbukkit/view/build-1330/?format=xml
like image 195
Gene Avatar answered Aug 12 '26 22:08

Gene