c# - Count how many children are contained inside a specific element -


i want count how many childs contained inside hometeam element.this number dynamic. use ,but gives me how many times hometeam shown.gives me 1

int cout = xmldoc.descendants("hometeam").count(); 

my xml :

<homestats>     <hometeam>         <hometeamname>pan</hometeamname>         <iperiod>74</iperiod>         <iiperiod>102</iiperiod>         <iiiperiod>124</iiiperiod>     </hometeam> </homestats> 

the answer in example is:the hometeam element contains 4 (hometeamname,iperiod,iiperiod,iiiperiod).so must 4. suggestion?

you're close. need add 1 more step; child elements:

int cout = xmldoc.element("hometeam").elements().count(); 

Comments

Popular posts from this blog

How to access named pipes using JavaScript in Firefox add-on? -

multithreading - OPAL (Open Phone Abstraction Library) Transport not terminated when reattaching thread? -

node.js - req param returns an empty array -