如何在Asp.net中使用HTTP Web服务?

我想根据http url返回的结果生成html内容。 http://www.zillow.com/webservice/GetDeepSearchResults.htm?zws-id=X1-ZWz1c239bjatxn_5taq0&address=2114+Bigelow+Ave&citystatezip=Seattle%2C+WA 此页面将为您提供一些XML结果。我想转换为使用该XML生成HTML。我不知道从哪里开始?有人会为asp.net提供任何指南或示例代码吗? 有关详细信息:http://www.zillow.com/howto/api/GetDeepSearchResults.htm     
已邀请:
要获取数据,你可以使用HttpWebRequest类,这是我必须提供的一个例子,但它可能会略微超出你的需求(你需要确保你做的正确 - 我怀疑上面是一个GET而不是POST)。
Uri baseUri = new Uri(this.RemoteServer);

HttpWebRequest rq = (HttpWebRequest)HttpWebRequest.Create(new Uri(baseUri, action));
rq.Method = "POST";
rq.ContentType = "application/x-www-form-urlencoded";

rq.Accept = "text/xml";
rq.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate;

Encoding encoding = Encoding.GetEncoding("UTF-8");
byte[] chars = encoding.GetBytes(body);
rq.ContentLength = chars.Length;

using (Stream stream = rq.GetRequestStream())
{
    stream.Write(chars, 0, chars.Length);
    stream.Close();
}

XDocument doc;
WebResponse rs = rq.GetResponse();
using (Stream stream = rs.GetResponseStream())
{
    using (XmlTextReader tr = new XmlTextReader(stream))
    {
        doc = XDocument.Load(tr);
        responseXml = doc.Root;
    }

    if (responseXml == null)
    {
        throw new Exception("No response");
    }
 }

 return responseXml;
一旦你获得了数据,你需要呈现HTML,很多很多选择 - 如果你只是想用最少的进一步处理将你已经获得的内容转换为HTML,那么你可以使用XSLT - 这是一个关于它的问题拥有。如果你需要用它做什么,那么问题太模糊了,你需要更具体。     
创建一个xsl样式表,并将样式表元素从teh页面注入到生成的xml中     

要回复问题请先登录注册