How should you complete the relevant code?

DRAG DROP
You are developing an application that will populate an extensive XML tree from a Microsoft
SQL Server 2008 R2 database table named Contacts.
You are creating the XML tree. The solution must meet the following requirements:
Minimize memory requirements.
Maximize data processing speed.
You open the database connection.
You need to create the XML tree.
How should you complete the relevant code? (To answer, drag the appropriate code
segments to the correct locations in the answer area. Each code segment may be used
once, more than once, or not at all. You may need to drag the split bar between panes or
scroll to view content.)

DRAG DROP
You are developing an application that will populate an extensive XML tree from a Microsoft
SQL Server 2008 R2 database table named Contacts.
You are creating the XML tree. The solution must meet the following requirements:
Minimize memory requirements.
Maximize data processing speed.
You open the database connection.
You need to create the XML tree.
How should you complete the relevant code? (To answer, drag the appropriate code
segments to the correct locations in the answer area. Each code segment may be used
once, more than once, or not at all. You may need to drag the split bar between panes or
scroll to view content.)

Answer:



Leave a Reply 9

Your email address will not be published. Required fields are marked *


Joe

Joe

I believe the second box answer is wrong, it should be the XElement and not the XAttribute as contacts. You can not have XElemets as childs of an XAtrribute.

Luden

Luden

Not 100 procent sure you are wrong, but contact is a attribute, while contacts is an element?

al adeeb

al adeeb

Joe is right, correct answer should be

XElement contacts =
new XElement(“contacts”,

kasp

kasp

Correct!
The following doesn’t generate a valid xml:

XAttribute contacts = new XAttribute(“contacts”,

宾宾

宾宾

I think the answer is this.

XNamespace ew = “ContactList”;
XElement root = new XElement(ew + “Root”);

Console.WriteLine(root);
XElement contact = new XElement(“contacts”,
//XAttribute contacts = new XAttribute(“contacts”,
from c in list
orderby c.ContactId
select new XElement(“contact”, new XAttribute(“contactId”, c.ContactId),
new XElement(“firstName”, c.FirstName),
new XElement(“lastName”, c.LastName))
);

root.Add(contact);

msdn

msdn

2.4.

J

J

I totally agree with you!

Arun Rana

Arun Rana

I agree with 宾宾 too.