将节点文本存储到arraylist中 [英] store node text into arraylist
本文介绍了将节点文本存储到arraylist中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
我想将XML节点文本存储到ArrayList中.我的XML文件如下所示:
hi guys,
i want to store a XML node text into a ArrayList. my XML file look like this:
<group>
<item1 id="1">
text1
</item1>
<item2 id="2">
text2
</item2>
</group>
我想将item1和item2作为文本存储到ArrayList中.
请帮助我.
I want to store a item1 and item2 as a text into ArrayList.
please help me in this.
推荐答案
嗨
我为您编写了一些代码,只需检查一下该代码
Hi
I Write some code for your requirement just check this code once
XmlDocument xmldoc = new XmlDocument();
xmldoc.Load(Server.MapPath("~/SomeFiles/XMLFile2.xml"));
XmlNodeList xmlnodli = xmldoc.SelectNodes("group");
List<string> strli = new List<string>();
foreach (XmlNode xm in xmlnodli)
{
strli.Add(xm.InnerText);
}
最好的
All the Best
这篇关于将节点文本存储到arraylist中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文