开发者

Pass through XML from another website

开发者 https://www.devze.com 2023-01-16 03:35 出处:网络
I am trying to pass through some XML from an external开发者_JS百科 website. What is the best way of doing this, through c# webpage or asp.MVC?I tend to use something like this for working with extern

I am trying to pass through some XML from an external开发者_JS百科 website.

What is the best way of doing this, through c# webpage or asp.MVC?


I tend to use something like this for working with external XML documents / RSS feeds etc:

string sURL = ".....";
// Create a request for the URL. 
WebRequest oRequest = WebRequest.Create(sUrl);
// Get the response.
WebResponse oResponse = oRequest.GetResponse();
// Get the stream containing content returned by the server.
Stream oDataStream = oResponse.GetResponseStream();
// Open the stream using a StreamReader for easy access.
StreamReader oReader = new StreamReader(oDataStream, System.Text.Encoding.Default);
// Read the content.
string sXML = oReader.ReadToEnd();
// Convert string to XML
XDocument oFeed = XDocument.Parse(sXML);


Either should be fine. MVC is probably easiest (in terms of getting a raw response), but you could do the same in regular ASP.NET just by using a handler (possibly .ashx), or just by clearing the response.

0

精彩评论

暂无评论...
验证码 换一张
取 消