Załóżmy mamy ten xml:Czy istnieje sposób pobierania elementów przy użyciu tylko lokalnych nazw w zapytaniu Linq-to-XML?
<?xml version="1.0" encoding="UTF-8"?>
<tns:RegistryResponse status="urn:oasis:names:tc:ebxml-regrep:ResponseStatusType:Failure"
xmlns:tns="urn:oasis:names:tc:ebxml-regrep:xsd:rs:3.0"
xmlns:rim="urn:oasis:names:tc:ebxml-regrep:xsd:rim:3.0">
<tns:RegistryErrorList highestSeverity="">
<tns:RegistryError codeContext="XDSInvalidRequest - DcoumentId is not unique."
errorCode="XDSInvalidRequest"
severity="urn:oasis:names:tc:ebxml-regrep:ErrorSeverityType:Error"/>
</tns:RegistryErrorList>
</tns:RegistryResponse>
aby pobrać RegistryErrorList elementu, możemy zrobić
XDocument doc = XDocument.Load(<path to xml file>);
XNamespace ns = "urn:oasis:names:tc:ebxml-regrep:xsd:rs:3.0";
XElement errorList = doc.Root.Elements(ns + "RegistryErrorList").SingleOrDefault();
ale nie podoba
XElement errorList = doc.Root.Elements("RegistryErrorList").SingleOrDefault();
Czy istnieje sposób, aby zrobić kwerendę bez przestrzeni nazw elementu. W zasadzie jest tam coś conceptially podobny do korzystania local-name() w XPath (tj // * [local-name() 'RegistryErrorList' =])