Just add the namespace to the LINQ to XML query. Since you have the default namespace declaration in the root directory node xmlns="http://schemas.microsoft.com/windows/2012/store/receipt" , you also need to include it in your request.
The following code shows an example:
XDocument doc = XDocument.Parse(receiptXml); XNamespace xmlns = "http://schemas.microsoft.com/windows/2012/store/receipt"; string date = doc.Root .Element(xmlns + "ProductReceipt") .Attribute("PurchaseDate") .Value; Console.WriteLine(date);
prints:
2013-05-20T19:27:09.755Z
There is also an agnostic namespace approach:
string date = doc.Root .Elements() .First(node => node.Name.LocalName == "ProductReceipt") .Attribute("PurchaseDate") .Value;
source share