I'm trying to load some xml into a XDocument. The XML data is provided by the city of Philadelphia, so that's not something I can change. I had a similar query before, which worked just fine. The xml response also seems to hold up in online XML validators, so how can I load it into my XDocument?
Here's my code, slightly simplified (first two lines taken and modified from another function).
string searchString = "http://services.phila.gov/PhillyApi/Data/v1.0/permits?$expand=locations&$filter=(issued_datetime%20gt%20Datetime%272012-12-01%27%20and%20issued_datetime%20le%20Datetime%272014-07-18%27)%20and%20(substringof(%27MAJOR%27,permit_type_code)%20or%20substringof(%27MINOR%27,permit_type_code)%20or%20substringof(%27PARIA%27,permit_type_code)%20or%20substringof(%27NEWCON%27,permit_type_code)%20or%20substringof(%27ENTIRE%27,permit_type_code))";
XDocument xResult = MakeRequest(searchString);
public static XDocument MakeRequest(string requestUrl)
{
HttpWebRequest request = WebRequest.Create(requestUrl) as HttpWebRequest;
HttpWebResponse response = request.GetResponse() as HttpWebResponse;
// This line causes the error 'root element missing'
XDocument xDoc = XDocument.Load(response.GetResponseStream());
return (xDoc);
}