ASP.NET从网站读取外部XML
发布时间:2020-12-16 09:32:00 所属栏目:asp.Net 来源:网络整理
导读:我想读一个位于 here的XML文件 数据看起来像这样 profile steamID6476561197967256555/steamID64 steamID![CDATA[snivfbo]]/steamID onlineStateoffline/onlineState stateMessage![CDATA[]]/stateMessage privacyStateprivate/privacyState visibilityState
我想读一个位于
here的XML文件
数据看起来像这样 <profile> <steamID64>76561197967256555</steamID64> <steamID><![CDATA[snivfbo]]></steamID> <onlineState>offline</onlineState> <stateMessage><![CDATA[]]></stateMessage> <privacyState>private</privacyState> <visibilityState>1</visibilityState> <avatarIcon><![CDATA[http://media.steampowered.com/steamcommunity/public/images/avatars/9d/9d13f8f8061b7adaa9e9c2766e2bb2b3d82f911c.jpg]]></avatarIcon> <avatarMedium><![CDATA[http://media.steampowered.com/steamcommunity/public/images/avatars/9d/9d13f8f8061b7adaa9e9c2766e2bb2b3d82f911c_medium.jpg]]></avatarMedium> <avatarFull><![CDATA[http://media.steampowered.com/steamcommunity/public/images/avatars/9d/9d13f8f8061b7adaa9e9c2766e2bb2b3d82f911c_full.jpg]]></avatarFull> <vacBanned>0</vacBanned> <isLimitedAccount>0</isLimitedAccount> </profile> 而我只是希望能够访问这些值.我对XmlTextReaders的了解有限,这让我无处可去.谢谢. 解决方法XDocument doc = XDocument.Load("http://steamcommunity.com/profiles/76561197967256555/?xml=1"); string steamID64 = doc.Root.Descendants("steamID64").First().Value; string steamID = doc.Root.Descendants("steamID").First().Value; string onlineState = doc.Root.Descendants("onlineState").First().Value; string stateMessage = doc.Root.Descendants("stateMessage").First().Value; string privacyState = doc.Root.Descendants("privacyState").First().Value; string visibilityState = doc.Root.Descendants("visibilityState").First().Value; string avatarIcon = doc.Root.Descendants("avatarIcon").First().Value; string avatarMedium = doc.Root.Descendants("avatarMedium").First().Value; string avatarFull = doc.Root.Descendants("avatarFull").First().Value; string vacBanned = doc.Root.Descendants("vacBanned").First().Value; string isLimitedAccount = doc.Root.Descendants("isLimitedAccount").First().Value; (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- asp.net – Web部署删除IIS网站自定义配置
- 在ASP.NET MVC 3中上载大于2GB的文件
- ASP.NET MVC4安全性,身份验证和授权
- asp.net-mvc – 使用ASP.NET MVC 3本地化非数据注释错误的最
- ASP.NET Core技术研究-探秘依赖注入框架
- ASP.NET MVC验证使用qTip jQuery插件
- asp.net – UpdatePanel回发后调用Javascript函数问题
- asp.net – 是否有可能检测到页面刷新(F5)服务器端?
- 在Asp.net中运行外部可执行文件的内存限制
- ASP.NET应用程序通过Windows身份验证或表单身份验证向Activ
推荐文章
站长推荐
- asp.net-mvc – 授权标签如何工作? – Asp.net
- asp.net – 如何在iframe中提交后刷新iframe父页
- asp.net-mvc – 验证在部分视图中不起作用
- asp.net-mvc – 变化:*错误地添加到http标头响应
- asp.net – 会话超时后重定向到登录页面
- asp-classic – ADODB.Stream错误’800a0bbc’写
- asp.net-mvc – redirectToAction导致null模型
- asp.net-mvc-2 – 在选择聚合时,如何处理Linq到N
- asp.net – 如何保护我的通用处理程序调用?
- asp.net – 如何以完全信任的方式部署IIS ASP .N
热点阅读