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

java - Intellij Synchronizing output directories .. -

git - Initial Commit: "fatal: could not create leading directories of ..." -