I'm getting the HttpWebResponse
as XML but it doesn't even start to look like an XML document because returned XML doesn't include the header
<?xml version='1.0' encoding='UTF-8'?>
and I am not able to parse it. It is throwing an exception
data at the root level is invalid line 1 position 1
or
System.Xml.XmlException: Root element is missing.
I tried all cases. I am not able figure this out.
using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
{
StreamReader responsereader = new StreamReader(response.GetResponseStream());
string responsedata = responsereader.ReadToEnd();
XmlDocument xmldoc = new XmlDocument();
xmldoc.load(responsedata);
}
The document I'm passing to the load()
method is along the lines:
<ns2:HotelListResponse>
<customerSessionId>0ABAA82C-EBAC-4791-3C22-4DEFAED93172</customerSessionId>
<numberOfRoomsRequested>0</numberOfRoomsRequested>
<moreResultsAvailable>false</moreResultsAvailable>
<HotelList activePropertyCount="198" size="198">
<HotelSummary order="0">
<hotelId>195974</hotelId>
...
</ns2:HotelListResponse>
I've provided just a snippet because of its length.