Dan McClain
Dan McClain

Reputation: 11920

Why won't this XPath query work on an .edmx file?

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?

Upvotes: 0

Views: 387

Answers (1)

Ben M
Ben M

Reputation: 22492

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

Upvotes: 1

Related Questions