DRAG DROP
You are developing a C# application. The application includes a class named Rate. The following code
segment implements the Rate class:
You define a collection of rates named rateCollection by using the following code segment:
Collection<Rate> rateCollection = new Collection<Rate>() ;
The application receives an XML file that contains rate information in the following format:
You need to parse the XML file and populate the rateCollection collection with Rate objects.
You have the following code:
Which code segments should you include in Target 1, Target 2, Target 3 and Target 4 to complete
the code? (To answer, drag the appropriate code segments to the correct targets in the answer are
a 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.)
Explanation:
* Target 1: The element name is rate not Ratesheet.
The Xmlreader readToFollowing reads until the named element is found.
* Target 2:
The following example gets the value of the first attribute.
reader.ReadToFollowing(“book”);
reader.MoveToFirstAttribute();
string genre = reader.Value;
Console.WriteLine(“The genre value: ” + genre);
* Target 3, Target 4:
The following example displays all attributes on the current node.
C#VB
if (reader.HasAttributes) {
Console.WriteLine(“Attributes of <” + reader.Name + “>”);
while (reader.MoveToNextAttribute()) {
Console.WriteLine(” {0}={1}”, reader.Name, reader.Value);
}
// Move the reader back to the element node.
reader.MoveToElement();
}
The XmlReader.MoveToElement method moves to the element that contains the current attribute
node.XmlReader Methods
https://msdn.microsoft.com/en-us/library/System.Xml.XmlReader_methods(v=vs.110).aspx
Target 4 should be reader.ReadToFollowing(“value”);
2,4,6,7