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

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

You need to retrieve the city of the first customer.

Which code segment do you use?

 Posted by Rajkatie on 8/31/2012 | Category: ADO.NET Interview questions | Views: 3005 | Points: 40
Select from following answers:
  1. string city = doc.FirstChild.FirstChild.SelectSingleNode("address").Attributes["city"].Value
  2. string city = doc.FirstChild.FirstChild.SelectSingleNode("address"). SelectSingleNode("city").Value;
  3. string city = doc.FirstChild.Attributes["address"].SelectSingleNode("city").Value;
  4. All Above

Show Correct Answer


Source: MeasureUp.Com | | Alert Moderator 

Comments or Responses

Login to post response