XElement element = XElement.Parse("The Book "); string author = element.Attribute("author").Value; Console.WriteLine(author); // Output: John Doe
XNamespace ns = "http://example.com"; XElement element = XElement.Parse("This example uses the Attribute method of the XElement class with an XNamespace value to retrieve the value of the "id" attribute in a namespace. Package library: System.Xml.Linq (https://www.nuget.org/packages/System.Xml.Linq/)The Book "); string id = element.Attribute(ns + "id").Value; Console.WriteLine(id); // Output: 101