XML ASMX 服务有 1 个返回值 - 不是 XDocument 那么如何解析?

发布于 2024-12-08 17:25:23 字数 382 浏览 9 评论 0原文

我试图从我没有创建的“XML Web 服务”返回一个值。它是一个 ASMX 服务,具有以下返回值:

<?xml version="1.0"?> 
123

其中值“123”根据我提供给服务的参数而变化。我的问题是,在 C# (Silverlight) 中,我如何解析这个值?

var webClient = new WebClient();
webClient.DownloadStringCompleted += webClient_DownloadStringCompleted;
webClient.DownloadStringAsync(service);

我没有看到一个简单的方法来获得这个值。

I am trying to return a value from an "XML Web Service" that I did not create. It is an ASMX service with the following return:

<?xml version="1.0"?> 
123

Where the value "123" varies depending on the parameters I feed the service. My question is, in C# (Silverlight), how can I parse this value?

var webClient = new WebClient();
webClient.DownloadStringCompleted += webClient_DownloadStringCompleted;
webClient.DownloadStringAsync(service);

I do not see an easy way to get to the value.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

地狱即天堂 2024-12-15 17:25:23

正如 John Saunders 所说,这不是 XML,因此您无法将其解析为 XML。

如果格式总是这么简单,只需获取第二行并使用它即可。

编辑:

如果您只想获得第二行,您可以使用类似以下内容的内容:

string result = downloaded.Split('\n')[1];

As John Saunders said, this is not XML, so you can't parse it as one.

If the format is always this simple, just get the second line and use that.

EDIT:

If it's just the second line you want to get, you can use something like:

string result = downloaded.Split('\n')[1];
平生欢 2024-12-15 17:25:23

这不是 XML,因此无法将其解析为 XML。

That's not XML, so there's no way to parse it as XML.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文