tags:

views:

56

answers:

1

I'm trying to get the list of EntityTypes in an EDMX file, and the following query returns no results:

XmlDocument edmxFile = new XmlDocument();
edmxFile.Load(args[0]);

XmlNamespaceManager nsMan = new XmlNamespaceManager(edmxFile.NameTable);
nsMan.AddNamespace("edmx", "http://schemas.microsoft.com/ado/2007/06/edmx");
nsMan.AddNamespace("s", "http://schemas.microsoft.com/ado/2007/06/edm/ssdl");
nsMan.AddNamespace("e", "http://schemas.microsoft.com/ado/2007/06/edm");
nsMan.AddNamespace("u", "urn:schemas-microsoft-com:windows:storage:mapping:SC");


XmlNodeList entityTypes =  edmxFile.DocumentElement.SelectNodes("//EntityType", nsMan); //Returns 0 nodes
XmlNodeList entityTypes =  edmxFile.SelectNodes("//EntityType"); //Returns 0 nodes also

Why doesnt XPath work here?

+1  A: 

It's been awhile, but I think you need "//s:EntityType" in your calls to those methods.

Ben M
That did not do the trick, and neither did any of the other namespaces
phsr
Just tried it myself, and it worked--the only modification I had to make was my ssdl (s:) namespace URI, which is `http://schemas.microsoft.com/ado/2006/04/edm/ssdl`. I assume you're using EF4, which is why you have a different URI?
Ben M
I'm using VS2008 SP1, after using the schema you did, it worked, thanks!
phsr