You are creating an application that performs contact management. You load customer information from the following XML to an XElement object named xElement:

<customers>
<customer id="7" phone="555-555-1211">
<name firstName = "Thomas" lastName = "Jensen"/>
<address street="12 Willow Way" city="Treeland" state="NJ" zip="14322" />
</customer>
<customer id="8" phone="555-555-1213">
<name firstName = "Henrick" lastName = "Jensen"/>
<address street="12 Willow Way" city="Treeland" state="NJ" zip="14322" />
</customer>
</customers>

You need to use XPATH retrieve the customer element with the id 8.
Which code segment do you use?

 Posted by Rajkatie on 9/1/2012 | Category: ADO.NET Interview questions | Views: 2764 | Points: 40
Select from following answers:
  1. XElement customer = xElement.XPathSelectElements("/customer[@id='8']").FirstOrDefault();
  2. XElement customer = xElement.XPathSelectElements("//id['8']").FirstOrDefault()
  3. XElement customer = xElement.XPathSelectElements("/customer/@id='8'").FirstOrDefault();
  4. All Above

Show Correct Answer


Source: MeasureUp.com | | Alert Moderator 

Comments or Responses

Login to post response