jmasterx
jmasterx

Reputation: 54113

Count number of entries?

I have an XML doc:

enter image description here

I have the XML doc here:

   XElement entries =
                    doc.Element("response").Element("entries");

How can I get a count of the number of entry in entries?

This example would be 2.

Upvotes: 1

Views: 93

Answers (2)

bash.d
bash.d

Reputation: 13207

Instead of Element() use Elements(), which delivers an IEnumerable<>. You can then count the number of entries. Using the Count()-method of IEnumerable<>.

See here for reference on MSDN.

Upvotes: 0

Hossein Narimani Rad
Hossein Narimani Rad

Reputation: 32481

Try this:

entries.Elements("entry").Count();

Upvotes: 5

Related Questions