将XML节点列表存储在arraylist中 [英] store xml nodelist in arraylist
本文介绍了将XML节点列表存储在arraylist中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在数据集或数组列表中存储xml节点列表..
请在此快速指南中为我提供帮助.
在此先感谢
how can i store a xml nodelist in dataset or arraylist..
please help me in this Quick.
thanks in advance
推荐答案
.NET框架的System.XML命名空间,对您的问题起着重要作用. Herez示例代码:
System.XML namespace of .NET framework, play a major role for your problem. Herez the sample code:
static void Main(string[] args)
{
XmlDocument xmldoc = new XmlDocument();
xmldoc.LoadXml("<root><node /><node /><node /></root>");
XmlNodeList xmlNodeList = xmldoc.SelectNodes("//node");
XmlNode[] array = (
new System.Collections.Generic.List<XmlNode>(
Migrate<XmlNode>(xmlNodeList))).ToArray();
}
public static IEnumerable<T> Migrate<T>(System.Collections.IEnumerable enumerable)
{
foreach (object current in enumerable)
{
yield return (T)current;
}
}
这篇关于将XML节点列表存储在arraylist中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文