asp.net如何读取类似于xml格式字符串中的节点值 5
<Return><ID>4df4a5ce</ID><Command>alarm</Command><IP>192.168.2.153</IP><CH>CH1</CH><N...
<Return><ID>4df4a5ce</ID><Command>alarm</Command><IP>192.168.2.153</IP><CH>CH1</CH><Name>温
度</Name><Value>39.3</Value><Unit>度
</Unit><Station>153</Station><Level>0</Level><ChannelType>1</ChannelType><Time>2012-3-5
13:37:08</Time><Start>2012-3-2
13:29:11</Start><Count>12914</Count><Span>2</Span><ID>df348907</ID><Command>alarm</Command><
IP>192.168.2.153</IP><CH>CH16</CH><Name>漏水
</Name><Value>1</Value><Unit></Unit><Station>153</Station><Level>0</Level><ChannelType>2</Ch
annelType><Time>2012-3-5 13:36:57</Time><Start>2012-3-2
13:29:20</Start><Count>12913</Count><Span>13</Span></Return> 展开
度</Name><Value>39.3</Value><Unit>度
</Unit><Station>153</Station><Level>0</Level><ChannelType>1</ChannelType><Time>2012-3-5
13:37:08</Time><Start>2012-3-2
13:29:11</Start><Count>12914</Count><Span>2</Span><ID>df348907</ID><Command>alarm</Command><
IP>192.168.2.153</IP><CH>CH16</CH><Name>漏水
</Name><Value>1</Value><Unit></Unit><Station>153</Station><Level>0</Level><ChannelType>2</Ch
annelType><Time>2012-3-5 13:36:57</Time><Start>2012-3-2
13:29:20</Start><Count>12913</Count><Span>13</Span></Return> 展开
2个回答
展开全部
可以自己写XML文档的读写,也可以用Linq to XML 要简单很多 网上有很多这方面的实例 可以Copy
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
using System.Xml.Serialization;
/// <summary>
/// 把XML文件序列化成对象
/// </summary>
/// <param name="fileFullName"></param>
/// <returns></returns>
public static LDTraining GetLDTraining(string fileFullName)
{
LDTraining training;
using (FileStream stream = new FileStream(fileFullName, FileMode.Open))
{
XmlSerializer sr = new XmlSerializer(typeof(LDTraining));
training = sr.Deserialize(stream) as LDTraining;
}
return training;
}
/// <summary>
/// 把XML文件序列化成对象
/// </summary>
/// <param name="fileFullName"></param>
/// <returns></returns>
public static LDTraining GetLDTraining(string fileFullName)
{
LDTraining training;
using (FileStream stream = new FileStream(fileFullName, FileMode.Open))
{
XmlSerializer sr = new XmlSerializer(typeof(LDTraining));
training = sr.Deserialize(stream) as LDTraining;
}
return training;
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询