exam questions

Exam 70-483 All Questions

View all questions & answers for the 70-483 exam

Exam 70-483 topic 2 question 112 discussion

Actual exam question from Microsoft's 70-483
Question #: 112
Topic #: 2
[All 70-483 Questions]

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 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.)
Select and Place:

Show Suggested Answer Hide Answer
Suggested Answer:
* 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.

Reference: XmlReader Methods -
https://msdn.microsoft.com/en-us/library/System.Xml.XmlReader_methods(v=vs.110).aspx

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
Mitsoshima
Highly Voted 5 years, 10 months ago
According to the answer of question #104 of topic 2, which handles the same question, the correct value of Target 4 should be: reader.ReadToFollowing("value"); If you call reader.MoveToElement() instead, the focused element is XML node 'rate', and not the desired XML node 'value'.
upvoted 33 times
...
osaki
Highly Voted 5 years, 4 months ago
Target 4 should be ReadToFlowing("value")
upvoted 13 times
...
DaGrooveNL
Most Recent 4 years, 3 months ago
FINAL ANSWER: 2. while(reader.ReadToFollowin("rate")) 4. reader.MoveToFirstAttribute(); 6. reader.MoveToNextAttribute(); 7. reader.ReadToFollowing("value");
upvoted 2 times
...
noussa
4 years, 3 months ago
Last one needs to be reader.ReadToFollowing("value") cause this is what MoveToElement do reader.MoveToElement(); // Moves the reader back to the element node.
upvoted 1 times
...
thiemamd
4 years, 9 months ago
Target 4 should be 'ReadToFollowing("value")' https://docs.microsoft.com/en-us/dotnet/api/system.xml.xmlreader.readtofollowing?view=netframework-4.8
upvoted 5 times
...
sscooter1010
5 years, 3 months ago
I tested this in code - reader.MoveToElement() does *not* work in this example.
upvoted 11 times
...
founderDev
5 years, 3 months ago
Correct Answer 2,4,6,7
upvoted 4 times
...
Igris
5 years, 4 months ago
it's not MoveElement https://docs.microsoft.com/en-us/dotnet/api/system.xml.xmlreader.movetoelement?view=netframework-4.8
upvoted 5 times
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...
exam
Someone Bought Contributor Access for:
SY0-701
London, 1 minute ago