Exercises

1. 

Which of these classes is an abstracted class?

  1. Node class

  2. Document class

  3. NodeList class

  4. All of the above

  5. None of the above

image from book

2. 

What is the difference between an object and a class?

  1. There is no difference between the two.

  2. A class is a structural definition.

  3. An object is a copy of a class.

  4. An object is an iteration of a class.

  5. All of the above.

image from book

3. 

Whats wrong with this script?

   <HTML><BODY> var xmlDoc; xmlDoc = ActiveXObject("Microsoft.XMLDOM"); xmlDoc.load("customers.txt"); </BODY></HTML>   
  1. There is nothing wrong with this script.

  2. Its loading a .txt file.

  3. A HEAD tag section, including a TITLE tag, is required.

  4. The keyword new is missing before ActiveXObject .

  5. None of the above.

  6. All of the above.

image from book

4. 

Which of the following commands returns a Document class object?

   a. xmlDoc.getElementsByTagName("name"); b. xmlDoc.documentElement.childNodes.item(0); c. xmlDoc.documentElement; d. xmlDoc.getElementsByTagName("name").item(1).attributes(0).name e. xmlDoc.getElementsByTagName("name").item(1).attributes(0).name   

image from book

Answers

1.  

Exercise 1 solution

a. Node class. Many of the other classes in the XML DOM inherit both attributes and methods from the Node class.

2.  

Exercise 2 solution

Choices b, c, and d are all true. A class defines structure and programmatic definition. One or more objects can be created from a single class making an object an iteration. Saying an object is a copy of a class is not strictly correct but it gets across the concept that the class and object are two different things. In a relational database a table could be a class, and the rows in the table the objects created against that class (the table), using the structure of the table as a blueprint from which to copy or duplicate from.

3.  

Exercise 3 solution

b. Its loading a .txt file. The file loaded should be an XML file with an .xml extension, such as customers.xml, and not customers.txt. d. The keyword new is missing before ActiveXObject. The script should look something like this:

   <HTML><BODY> <SCRIPT LANGUAGE="JavaScript"> var xmlDoc; xmlDoc = new ActiveXObject("Microsoft.XMLDOM"); xmlDoc.load("customers.xml"); </SCRIPT> </BODY></HTML>   

4.  

Exercise 4 solution

a. returns an element. b. returns the first item in a collection. c. is the correct answer returning a Document class object. d. returns an attribute name. e. returns an attribute value.



Beginning XML Databases
Beginning XML Databases (Wrox Beginning Guides)
ISBN: 0471791202
EAN: 2147483647
Year: 2006
Pages: 183
Authors: Gavin Powell

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net