Click here to Skip to main content
15,884,298 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi guys,

i want to store a XML node text into a ArrayList. my XML file look like this:

HTML
<group>
<item1 id="1">
text1
</item1>

<item2 id="2">
text2
</item2>
</group>


I want to store a item1 and item2 as a text into ArrayList.

please help me in this.
Posted
Updated 10-Oct-11 0:04am
v2

1 solution

Hi
I Write some code for your requirement just check this code once

C#
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
 
Share this answer
 
v2
Comments
Venkatesh Mookkan 10-Oct-11 6:11am    
Good answer!
Member 8214635 11-Oct-11 0:54am    
when i used this code it store a full node with attribute like:
<item2 id="2">

know what i do please help me in this
Member 8214635 11-Oct-11 0:55am    
item2 id="2"
Muralikrishna8811 11-Oct-11 4:12am    
place condition in foreach loop
like

if(xm.attribute["id"]==2)
{
}

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900