c# - Xml attributes to string array -


how "cc" attribute values below xml string array

<dd a="1" b="2" c="3">    <d aa="11" bb="22" cc="33"/>    <d aa="11" bb="22" cc="33"/>    <d aa="11" bb="22" cc="33"/> </dd>   

cases tried:

foreach (xmlnode xd in dd) {                         xmlelement getfdd = (xmlelement)dd;                         (int x = 0; x < dd.childnodes.count; x++)                         {                             xmlelement xmlfv = (xmlelement)dd.childnodes[x];                             stringarr[x] = xmlfv.getattribute("cc");                                                 }                     } 

and

   (int u = 0; u < dd.count; u++)                     {                         getfdd = (xmlelement)dd[u].firstchild;                         xmlelement getfdd1 = (xmlelement)getfdd;                         stringarr[u]=getfdd1.getattribute("cc"); } 

i tried using foreach loop through each node, gave trying that.

this should work .net 2.0

var doc = new xmldocument(); doc.load(fname);  list<string> list = new list<string>(); foreach(xmlnode node in doc.getelementsbytagname("d")) {     list.add(node.attributes["cc"].value); } 

Comments

Popular posts from this blog

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -