XPath and *.csproj
Look at the root namespace; you'll have to include an xml-namespace manager and use queries like "//x:ItemGroup", where "x" is your designated alias for the root namespace. And pass the manager into the query. For example:
XmlDocument doc = new XmlDocument();
doc.Load("my.csproj");
XmlNamespaceManager mgr = new XmlNamespaceManager(doc.NameTable);
mgr.AddNamespace("foo", doc.DocumentElement.NamespaceURI);
XmlNode firstCompile = doc.SelectSingleNode("//foo:Compile", mgr);
You probably need to add a reference to the namespace http://schemas.microsoft.com/developer/msbuild/2003
.
I had a similar problem, I wrote about it here. Do something like this:
XmlDocument xdDoc = new XmlDocument();
xdDoc.Load("blah/blah.csproj");
XmlNamespaceManager xnManager =
new XmlNamespaceManager(xdDoc.NameTable);
xnManager.AddNamespace("tu",
"http://schemas.microsoft.com/developer/msbuild/2003");
XmlNode xnRoot = xdDoc.DocumentElement;
XmlNodeList xnlPages = xnRoot.SelectNodes("//tu:ItemGroup", xnManager);