XML Parser - Quiz Explanation
The answers you selected are indicated below, along with text that explains the correct answers.
1.
Which of the following operations is performed by a validating parser?
Please select the best answer.
A.
It checks an XML document for well-formedness.
B.
It checks the XML document for validity.
C.
It checks the XML document for well-formedness and validity.
D.
It parses an XML document using the DOM model.
The correct answer is C.
A validating parser checks the XML document for well-formedness and validity. Answer A is incorrect because a validating parser does not check for well-formedness only. All parsers are required to check for well-formedness. Answer B is incorrect because a validating parser checks for both well-formedness and validity. Answer D is incorrect because a validating parser may or may not use the DOM model.
2.
Which of the following statements describes how the DOM works?
Please select the best answer.
A.
DOM generates a tree-like structure for the entire contents of the document.
B.
DOM is based on events.
C.
DOM is used only by validating parsers.
D.
DOM is used only by non-validating parsers.
The correct answer is A.
The DOM generates a tree-like structure for the entire contents of an XML document. Answer B is incorrect because DOM is not based on events --SAX is. Answer C is incorrect because validating as well as non-validating parsers may use the DOM model. Answer D is incorrect because validating and non-validating parsers may use the DOM model.
3.
What is the first step in using an XML parser in an application?
Please select the best answer.
A.
Process the input XML document.
B.
Create a parser object instance.
C.
Use methods of the DOM to retrieve element contents.
D.
D:
E.
Pass the XML document to the parser.
The correct answer is B
. The first step in using an XML parser in an application is to create a parser object instance. Answer A is incorrect because an XML document cannot be processed prior to creating a parser instance. Answer C is incorrect because the methods of the DOM may only be invoked after creating a parser instance. Answer D is incorrect because a parser object must exist before the document can be passed to it.