Select from following answers:- XElement customer = customersRootElement.Elements("customer") .Where(el => el.Attributes("id").Any(a => (string) a == "7")) .FirstOrDefault();

- XElement customer = xElement.Elements("customer") .Where(el => el.Attributes("id").Any(a => (string)a == "7"));
- XElement customer = customersRootElement.Attributes("customer") .Where(a => (string)a == "7").FirstOrDefault();
- All Above
To retrieve the customer element with the id 7, retrieve customer elements by using the Elements method. Retrieve each customer element's attributes by using the Attributes method specifying attributes with the name "id" and the value "7".
You cannot retrieve customer elements by searching the root elements Attributes collection. This collection gives root attributes, not elements.
Show Correct Answer
Source: MeasureUp.com | |
Alert Moderator