I'm trying to parse xml from a website, and I'm getting the error "Data at the root level is invalid. Line 1, position 1.
Here is the website output:
<Forecast xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Days>
<Day>
<date>16/06/2016</date>
...etc
I don't know why the first line is causing an error, but is it possible to skip that line when I'm reading, and just get to the Days element? I've read other questions on here that have this same error but none of the solutions worked for me.
I'm trying to read the xml this way:
XmlDocument doc1 = new XmlDocument();
doc1.Load(url);
XmlElement root = doc1.DocumentElement;
XmlNodeList nodes = root.SelectNodes("/Forecast/Days/Day");
foreach (XmlNode node in nodes)
{
string max = node["temp_max_f"].InnerText;
string min = node["temp_min_f"].InnerText;
string date = node["date"].InnerText;
Console.WriteLine("{0} {1} {2}", date, max, min);
}