Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Microsoft CSharp Programming For The Absolute Beginner (2002) [eng].pdf
Скачиваний:
39
Добавлен:
16.08.2013
Размер:
15.71 Mб
Скачать

Chapter 10: Chapter Basic XML: The Quiz Maker

Since the late 1990s, there has been a great deal of interest in a technology called XML (eXtended Markup Language). XML has promised to transform many types of programming, and support of XML is one selling point of the .NET framework. You will now learn how to incorporate XML in your programs. In this chapter you will learn how to do the following tasks:

Recognize the basic rules of XML syntax.

Associate various parts of an XML document with the appropriate .NET classes.

Navigate through the elements and nodes of an XML document.

Store data in an XML structure.

Retrieve data from an XML structure.

Store and load XML documents to files.

Introducing the Quiz Maker Game

I wrote a simple quiz game to illustrate the use of XML. The quiz program opens with a main screen that calls two other forms (see Figure 10.1). The quiz form allows the player to take a quiz, and the editor form allows the user to create and modify quizzes. However, rather than rely on object serialization as a storage technique as the Adventure Kit game does, the quiz files are stored as XML documents. XML provides several advantages, which are described in the upcoming section “Investigating XML.”

Figure 10.1: The main screen allows quick access to the other forms of the quiz program.

Taking a Quiz

The quiz program serves a series of multiple−choice questions. The user can select an answer with radio buttons and can move between questions with the Next and Prev buttons. Figure 10.2 shows the quiz program in action.

277

Соседние файлы в предмете Программирование на C++