C#怎么读取Xml文件的节点值

最终的阿瓦隆 2012-04-27 01:01:13
<?xml version="1.0" encoding="GBK"?>
-<smartresult>
-<product type="ip">
<ip>49.76.255.175</ip>
<location>美国 亚利桑那州JITCNET</location>
</product>
</smartresult>

我请求某个服务器返回的xml数据,
我想把<ip></ip>和<location></locaton>里的值取出来显示在界面上。怎么做。
...全文
71 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
最终的阿瓦隆 2012-04-27
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 的回复:]

doc.SelectSingleNode("/smartresult/product/ip").InnerText
doc.SelectSingleNode("/smartresult/product/location").InnerText
[/Quote]
已经实现,看来我有必要去看看xml。目前正好是项目遇到。临时用下。日后再来补下。
孟子E章 2012-04-27
  • 打赏
  • 举报
回复
doc.SelectSingleNode("/smartresult/product/ip").InnerText
doc.SelectSingleNode("/smartresult/product/location").InnerText

110,536

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧