Chapter Summary

In this chapter, you were introduced to XML by learning its purpose, definition, and basic syntax. You also learned how to open and save XML documents from the Excel application window and the advantages of adding the data to an Excel list. Finally, you learned how to use several new objects in the Excel object model designed to support XML. This included the XmlMap object and the ListObject object and some of their associated and/or subordinate objects. For the chapter project, you revisited the Math Game by adding XML support such that the program's data was stored in XML document files.

r

Challenges

1.

Open your favorite text editor, then enter and save the following with an .xml

file extension.

<?xml version="1.0" encoding="UTF-8"?>

<myData>

<myElement>

<ranData1>A</ranData1>

<ranData2>1</ranData2>

</myElement>

<myElement>

<ranData1>B</ranData1>

<ranData2>2</ranData2>

</myElement>

</myData>

2.

Open your xml file in Excel as an XML list. From the Source Task Pane

(select Data, XML, XML Source) select the different elements in the XML map

and note what is selected in the worksheet. Add a couple more rows of data to

the list by first selecting the insert row (the row marked with an asterisk *) and

entering random values. With the list selected, export the data to the same

XML file by selecting Data, XML, Export. Finally, re-open the file in a text editor

and note the change from the original.

3.

Clear the data from the XML list in Challenge 2 then refresh the list by selecting

Data, XML, Refresh XML Data.

4.

Write a VBA procedure that exports the data from your XML list created in

Challenge 2 to a new XML file.

5.

Write a VBA procedure that refreshes the data in your XML list created in

Challenge 2.

6.

Write a VBA procedure that outputs the schema text associated with the XML

map created in Challenge 2 to a text file. Hint: use the XML property of the

XmlSchema object to retrieve the schema text. Next, use the Open statement

(see Chapter 7) to save the schema text.

(continues)

Challenges (continued)

7. Revise the Math Game program to allow students to skip problems. While taking a test, the program should repeat skipped problems after the student has answered the last problem.

8. Revise the Math Game program to force students to sign in to take a test using a password. Passwords should be saved in the students.xml document file.

9. Revise the Math Game program to store the complete results of each exam. This includes the answers entered by the student and the length of time taken to finish.

10. Revise the Math Game program to allow a user to quickly view basic statistics regarding test results. For example, the program should calculate the average score on a particular test, the average number of attempts per test, and so on.

This page intentionally left blank

(chapter)

Biorhythm Awareness

Biorhythm Awareness

Who else wants to take advantage of biorhythm awareness to avoid premature death, escape life threatening diseases, eliminate most of your life altering mistakes and banish catastrophic events from your life.

Get My Free Ebook


Post a comment