Read XML Attribute using C# -


    <block id="ar0010100" box="185 211 825 278" element_type="h1" seq_no="0" /> 

this example xml code. in c# need store id's inside of block element in 1 variable, , box's inside of block element. have been trying 2 days, , don't know how narrow down question.

xmlnodelist idlist = doc.selectnodes("/block/id"); 

doesn't work... version of doc.selectnode, doc.getelementby... doesn't return right element/children/whatever call it. i'm not able find documentation tells me i'm trying reference. don't know if id or box children, if they're attributes or what. first time using xml, , can't seem narrow down problem.

you can use following code

 xmlnodelist elemlist = doc.getelementsbytagname("your element"); (int = 0; < elemlist.count; i++) {     string attrval = elemlist[i].attributes["id"].value; } 

demo: https://dotnetfiddle.net/5ppnpk

the above code taken here read xml attribute using xmldocument


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -