Tuesday, December 20, 2016

XML Quiz


XML (eXtensible Markup Language) defines rules to create and store documents in a text format. It is extensively used to transfer encoded data over the internet between different applications. You can learn XML from my XML coding tutorial 1 and XML coding tutorial 2.
If you are into web applications, it is important to know XML along with HTML, CSS and JavaScript. XML looks deceptively simple on the surface but it has many features. Try this quiz to find out how well you know XML.
 
1. Which of these names of XML elements is correct?
<first name>
<xml>
<1phoneNumber>
<a:>

2. What can you say about the following XML?
<people>
<Person>
<firstName>John</firstName>
<lastName>Smith</lastname>
</Person>
</people>
It is well-formed i.e. it follows the XML syntax rules.
It is valid i.e. it is validated by a DTD.
It has exactly one error.
It has multiple errors.

3. Where can an XML element contain data?
Own attribute(s).
Own text
Child elements and their data
Any or all of the above

4. Which of the following statements is true?
XML stores white spaces while HTML ignores white spaces.
XML tags are case insensitive.
All XML tag names must be in lowercase.
XML attributes can be optionally enclosed in double quotes.

5. How can you specify an attribute with multiple values?
<Node attribute="value1" attribute="value2">
<Node attribute="value1 value2">
<Node attribute="value1, value2">
An attribute cannot be duplicated.

6. In JavaScript, which of these is a correct method of XMLDocument object (an XML document in memory)?
createElements
createTextNode
getElementByTagName
exact:* Summary

7. What is the benefit of an XML namespace?
It allows elements and attributes with identical names to be named uniquely.
It provides information about an industry vocabulary.
It results in longer element or attribute names.
All of the above.

8. What is the best way of validating an XML document?
Use a custom JavaScript validator.
Validate using in-line DTD.
Validate using external DTD.
Validate using XML Schema.

9. Which XML DOM method is used to read the value of an attribute of an XML element?
getAttribute
getElementsByTagName
setAttribute
appendAttribute

10. Which technology is used to transform XML into HTML?
XHTML
XSLT
DOM
XPath
Score is 0/ 10.

The questions were not so simple, were they? Hope you enjoyed analyzing the answer choces. Please mention your scores in the comments below.
Until next time.