The namespace of doc-number
is http://www.epo.org/exchange
. It has been inherited from the root node. You need to specify that in your query. Furthermore, doc-number
isn't an element - i.e. direct child - of exchange-document
. It is a descendant.
XNamespace d = "http://www.epo.org/exchange";
var bib = from exchange in xDoc.Descendants(xn + "exchange-document")
where (string)exchange.Attribute("kind") == "A1"
select new biblio
{
appNumber = (string)exchange.Descendant(d + "doc-number")
};
Please note that I changed exchange.Attribute("kind").Equals("A1")
to (string)exchange.Attribute("kind") == "A1"
and exchange.Descendant(d + "doc-number").Value
to (string)exchange.Descendant(d + "doc-number")
.
That prevents NullReferenceException
s if the attribute or descendant doesn't exist.