See the question and my original answer on StackOverflow

When you a SelectNodes or SingleSelectNodes returns nothing, it means your query is wrong. In this case, elements in a .csproj belong to a namespace (here declared as the "default" namespace - w/o a prefix)

<Project ... xmlns="">

So your code must be changed into this:

XmlDocument doc = new XmlDocument();
XmlNamespaceManager nsmgr = new XmlNamespaceManager(new NameTable());
nsmgr.AddNamespace("p", "");
XmlNode node = doc.SelectSingleNode(@"/p:Project/p:ItemGroup/p:Reference[@Include='System.Data']", nsmgr);



Note the prefix "p" can be anything, it just allows you to specify a corresponding namespace in the XPATH expression, but you need it, even if in the original document it's declared as the default namespace.