我有一个生成 XML 的 php 服务。如何在 C# 中解析 XML?我尝试使用这样的东西:
WebRequest request = WebRequest.Create("http://devstage.jokeroo.com/rest.php");
request.Method = "GET";
request.ContentType = "text/html";
IAsyncResult result = request.BeginGetResponse(RequestCallback, request);
private void RequestCallback(IAsyncResult ar)
{
var request = ar.AsyncState as WebRequest;
Stream reader = request.EndGetResponse(ar).GetResponseStream();
//use this reader to read the content
}
但它不断抛出这个异常:
'System.Net.ProtocolViolationException'
发生类型异常System.Windows.ni.dll
但未在用户代码中处理
有什么建议么?