I have the following XML file (it's actually VS2010 dbproj file)
<?xml version="1.0" enconding="utf-8"?>
<Project.....>
<propertyGroup>
....
</PropertyGroup>
<ItemGroup>
<Build Include = "Schema Objects\Schemas\dbo\Programmability\Stored Procedures\foo.sql>
</Build>
</ItemGroup>
</Project>
I would like to use LINQ to XML to extract all Build elements that are Stored Procedures. I have the following code, which doesn't seem to work:
var doc = XDocument.Load(filePath);
var elements = doc.Descendants("Build").Where( x => x.Attribute("Include").Value.Contains("Stored Procedure")).ToList();
What is the right way of extracting the attribute values?
Thanks for the replies! It turned out that there was a namespace specified in the Project tag which I omitted. That's why I was getting 0 results back.