The problem is that I can not get any results if the node contains namespace/attribute. This is the code:
Dim xmlFromDisk = XDocument.Load(\"customers.xml\")
Dim
Sure, so you need to specify the namespace as well. xmlns="..."
indicates the default namespace for any unqualified descendant elements.
I don't know how you'd do it in an XML literal in VB, but in C# you'd just write:
XNamespace ns = "http://tempuri.org/";
var ukCustomers = doc.Root
.Elements(ns + "Customer")
.Where(x => (string) x.Element(ns + "Country") == "UK");
EDIT: This is the equivalent VB code as shown by Reflector and hacked around a bit by me:
Dim ns As XNamespace = "http://tempuri.org/"
Dim ukCustomers =
(From x In doc.Root.Elements(DirectCast((ns + "Customer"), XName))
Where (CStr(x.Element(ns + "Country")) = "UK")
Select x)