Possible Duplicate:
Understanding Linq To Xml - Descendants return no results
So I've been looking at the Microsoft example:
http://msdn.microsoft.com/en-us/library/bb387061.aspx
There, they do like this:
IEnumerable<string> partNos =
from item in purchaseOrder.Descendants("Item")
select (string) item.Attribute("PartNumber");
They use "Descendants" to address an item in purchaseOrder which is actually 3 levels deep.
Now, when I try to do the same thing with my XML, I get nothing.
My XML:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<name>Roulette</name>
<modules>
<module>application</module>
<module>test</module>
</modules>
My code:
XDocument mainPOM = XDocument.Load(above_xml);
List<string> pomLocations = (from loc in mainPOM.Descendants("module") select (string)loc.Name.LocalName).ToList();
Console.WriteLine(pomLocations.Count);
Unfortunately, pomLocations has a length of 0 :(.
Can somebody please tell me where exactly am I messing up?