如何在C#中一个XmlNode得到的参数值 [英] How to get parameter values from an XmlNode in C#

查看:170
本文介绍了如何在C#中一个XmlNode得到的参数值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何获得的值在XmlNode的变量参数。例如:

 <天气时间布局=K-p24h-N7-1> 
<名称>天气类型,覆盖面广,强度和LT; /名称>
<气象条件的天气汇总=晴/>
< /天气>



我想在这个节点的天气条件参数天气摘要的价值。


解决方案

  VAR节点= xmldoc.SelectSingleNode(天气/气候条件); 
VAR ATTR = node.Attributes [天气摘要];


How do I get the values for parameters in a XmlNode tag. For example:

<weather time-layout="k-p24h-n7-1">
    <name>Weather Type, Coverage, and Intensity</name>
    <weather-conditions weather-summary="Mostly Sunny"/>
</weather>

I want to get the value for the parameter 'weather-summary' in the node 'weather-conditions'.

解决方案

var node = xmldoc.SelectSingleNode("weather/weather-conditions");
var attr = node.Attributes["weather-summary"];

这篇关于如何在C#中一个XmlNode得到的参数值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆