【发布时间】:2016-12-11 06:13:54
【问题描述】:
xml 位于此处:
https://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml
我想获取元素<Cube time="2016-08-04">的time属性。
我的 C# 代码如下,但出现错误。
private string function()
{
XmlDocument Doc = new XmlDocument();
Doc.Load("https://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml");
XmlNamespaceManager nsmgr = new XmlNamespaceManager(Doc.NameTable);
nsmgr.AddNamespace("gesmes", "http://www.gesmes.org/xml/2002-08-01");
XmlNodeList nodes = Doc.SelectNodes("gesmes:Envelope/Cube", nsmgr);
XmlNode node = nodes[0].SelectSingleNode("Cube");
return node.Attributes["time"].Value;
}
错误(我从网络服务调用它):
错误就在这一行
XmlNode node = nodes[0].SelectSingleNode("Cube");
错误:
由于内部错误,服务器无法处理请求。有关该错误的更多信息,请在服务器上打开 IncludeExceptionDetailInFaults(来自 ServiceBehaviorAttribute 或来自配置行为)以便将异常信息发送回客户端,或者根据 Microsoft .NET Framework SDK 文档打开跟踪并检查服务器跟踪日志。
服务器堆栈跟踪:
在 System.ServiceModel.Channels.ServiceChannel.ThrowIfFaultUnderstood(消息回复、MessageFault 故障、字符串操作、MessageVersion 版本、FaultConverter faultConverter)
在 System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime 操作,ProxyRpc& rpc)
在 System.ServiceModel.Channels.ServiceChannel.Call(字符串操作,布尔单向,ProxyOperationRuntime 操作,Object[] 输入,Object[] 输出,TimeSpan 超时)
在 System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime 操作)
在 System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage 消息)在 [0] 处重新抛出异常:
在 System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
在 System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 类型)
在 IRate.DoWork() 在 RateClient.DoWork()
【问题讨论】: