tags:

views:

32

answers:

1

Hi there,

I have an XDocument in the format:

<S xmlns="http://server.com/DAAPI"&gt;
   <TIMESTAMP>2010-08-17 10:14:31.937</TIMESTAMP>
   <REP_GROUP>
     <GROUP></GROUP>
     <NAME></NAME>
     <LOCAL_NAME></LOCAL_NAME>
                 ........
   </REP_GROUP>
   <REP_GROUP>
    <GROUP>AMZ </GROUP>
    ..............

Why when I do

XNamespace ns = "http://server.com/DAAPI";
xDocument.Elements( ns + "REP_GROUP" ).Count()

do i get a count of zero?

+1  A: 

Assuming your variable name is accurate, it's because your document only has one element - <S>, the root element. Try this:

int count = xDocument.Root.Elements(ns + "REP_GROUP" ).Count();
Jon Skeet