my url is :
http://localhost:8983/solr/db/select/?q=searchtext&version=2.2&start=0&rows=10&indent=on
How can i get response (xml data) from this url in asp.net. my result search is :
WebRequest request = WebRequest.Create(url);
WebResponse response = request.GetResponse();
String a = response.ResponseUri.ToString();
But, I cant get content of xml data.
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
Stream receiveStream = response.GetResponseStream();
StreamReader readStream = new StreamReader(receiveStream, Encoding.UTF8);
String a = readStream.ReadToEnd();
ResponseUri is just the URL for the response. You need to use GetResponseStream().
You should probably be using the XmlDocument class.
http://msdn.microsoft.com/en-us/library/system.xml.xmldocument.aspx
Your code would look something like this:
XmlDocument doc = new XmlDocument();
doc.Load(response.GetResponseStream());
string root = doc.DocumentElement.OuterXml;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.