70-516 · Question #53
You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4.0 to create an application. The application contains the following XML document: <bib> <book title="TCP/IP Illusrated"…
The correct answer is C. return doc.Elements("bib").Elements(). See the full explanation below for the reasoning.
Question
You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4.0 to create an application. The application contains the following XML document:
<bib> <book title="TCP/IP Illusrated" year="1994"> <author>Author1</author> </book> <book title="Programming in UNIX" year="1992"> <author>Author1</author> <author>Author2</author> <author>Author3</author> </book> <book title="Data on the web" year="2000"> <author>Author4</author> <author>Author3</author> </book> </bib> You add the following code fragment. (Line numbers are included for reference only.) 01 public IEnumerable<XElement> GetBooks(string xml) 02 { 03 XDocument doc = XDocument.Parse(xml); 04 ... 05 } You need to return a list of book XML element that are authored by Author1. Which code segment should you insert at line 04?
Options
- Areturn doc.Element("bib").Elements()
- Breturn doc.Element("bib").Elements()
- Creturn doc.Elements("bib").Elements()
- Dreturn doc.Elements("bib").Elements()
How the community answered
(35 responses)- A3% (1)
- B11% (4)
- C80% (28)
- D6% (2)
Community Discussion
No community discussion yet for this question.