PrepAway - Latest Free Exam Questions & Answers

Which code segment should you insert at line 07?

You are creating a Windows Forms application for a book retailer by using the .NET Framework 3.5.
You are creating a Windows form to allow users to maintain a list of books in an XML document.
You write the following code segment. (Line numbers are included for reference only.)

01 XmlDocument xmlDoc = new XmlDocument();
02 XmlNode bookstore = xmlDoc.CreateElement("bookstore");
03 xmlDoc.AppendChild(bookstore);
04 XmlElement book = xmlDoc.CreateElement("book");
05 book.SetAttribute("ISBN", strISBN);
06 XmlElement title = xmlDoc.CreateElement("title");
07

The variables strTitle and strISBN are already initialized with the necessary values.
You need to ensure that after the form is complete the XML document has the following structure.

<bookstore>
<book ISBN="n-nnn-nnnnn-nn">
<title>Title</title>
</book>
</bookstore>

Which code segment should you insert at line 07?

PrepAway - Latest Free Exam Questions & Answers

A.
title.InnerText = strTitle;book.AppendChild(title);
bookstore.AppendChild(book);

B.
title.InnerText = strTitle;book.AppendChild(bookstore);
bookstore.AppendChild(title);

C.
title.Value = strTitle;book.AppendChild(title);
bookstore.AppendChild(book);

D.
title.Value = strTitle;bookstore.AppendChild(title);
book.AppendChild(bookstore);


Leave a Reply