XML MCQ Banner

XML Multiple Choice Questions (MCQs) and Answers

Master XML with Practice MCQs. Explore our curated collection of Multiple Choice Questions. Ideal for placement and interview preparation, our questions range from basic to advanced, ensuring comprehensive coverage of Extensible Markup Language (XML) concepts. Begin your placement preparation journey now!

Q61

Q61 Which XPath expression retrieves all title elements inside bookstore?

A

bookstore/title

B

/bookstore/title

C

//bookstore/title

D

bookstore//title

Q62

Q62 Which XPath expression selects the price element of the second book in bookstore?

A

/bookstore/book[2]/price

B

//book[2]/price

C

/bookstore//price[2]

D

//bookstore/price[2]

Q63

Q63 What does the following XPath expression return:
//book[last()]?

A

The first book element

B

The last book element

C

All book elements

D

The parent of all book elements

Q64

Q64 Which XPath expression selects all book elements that have a price greater than 30?

A

//book[price>30]

B

//book[@price>30]

C

//book[price>="30"]

D

//book[price>'30']

Q65

Q65 Why does the following XPath expression cause an error?
/library/book[@id=001]

A

@id must be enclosed in quotes

B

XPath does not support attributes

C

The path should start with //

D

The id attribute must be numeric

Q66

Q66 An XPath query /bookstore/book/title returns an empty result. What is the likely cause?

A

The XML document does not contain books

B

The XPath query is incorrect

C

The XML structure does not match the query

D

The XPath query should use // instead of /

Q67

Q67 An XPath query //book[3]/title does not return a result, even though books exist. What is the problem?

A

The XML document has fewer than three books

B

The title elements are missing

C

The XPath query syntax is incorrect

D

The index should be 2 instead of 3

Q68

Q68 What is the purpose of XSLT?

A

To query XML data

B

To transform XML documents into other formats

C

To validate XML documents

D

To encrypt XML data

Q69

Q69 Which of the following best describes XSLT?

A

It is a scripting language

B

It is a declarative transformation language

C

It is a subset of Java

D

It is used to style XML

Q70

Q70 How does XSLT process an XML document?

A

Sequentially, like a script

B

Using pattern matching and templates

C

By compiling XML into binary

D

By executing JavaScript

Q71

Q71 What is an XSLT template?

A

A function that modifies XML

B

A set of rules applied to elements

C

A script that runs on the server

D

A schema for XML validation

Q72

Q72 Which of the following XSLT elements is used to iterate over XML nodes?

A

<xsl:apply-templates>

B

<xsl:for-each>

C

<xsl:if>

D

<xsl:choose>

Q73

Q73 Which XSLT element is used to apply a transformation rule?

A

<xsl:apply-templates>

B

<xsl:value-of>

C

<xsl:transform>

D

<xsl:attribute>

Q74

Q74 What does the <xsl:value-of select="name"/> statement do?

A

Sets a new XML value

B

Selects the text value of the name element

C

Deletes the name element

D

Applies a CSS style to name

Q75

Q75 How do you conditionally apply a transformation in XSLT?

A

Using <xsl:choose>

B

Using JavaScript

C

Using CSS styles

D

Using <xsl:apply-if>

Q76

Q76 What does the following XSLT code do?
<xsl:template match="book"><h2><xsl:value-of select="title"/></h2></xsl:template>

A

Deletes book elements

B

Replaces book elements with h2

C

Outputs the title inside an h2 tag

D

Ignores book elements

Q77

Q77 Why does an XSLT transformation fail when applied to an XML document?

A

The XML document is missing a DTD

B

The XML document is not well-formed

C

The XML document contains an inline schema

D

The XSLT file is too large

Q78

Q78 An XSLT transformation does not apply to some XML elements. What is the most likely cause?

A

The elements do not have matching templates

B

XSLT does not support transformation

C

The XML file is encrypted

D

XSLT is case-insensitive

Q79

Q79 Why would the following XSLT code not work?
<xsl:template match="title"><p><xsl:value-of select="." /></p></xsl:template>

A

title is not a valid XML element

B

The template should match //title instead

C

title is an attribute, not an element

D

XSLT does not support text nodes

Q80

Q80 What is XML parsing?

A

Converting XML to binary

B

Processing XML to extract data

C

Encrypting XML files

D

Compressing XML documents

Q81

Q81 Which of the following is a characteristic of DOM parsing?

A

Processes XML sequentially

B

Loads the entire XML document into memory

C

Cannot modify XML

D

Uses event-based processing

Q82

Q82 What is an advantage of SAX parsing over DOM parsing?

A

SAX parsing allows direct modification of XML

B

SAX is event-driven and uses less memory

C

SAX is faster for small files

D

SAX loads the entire XML document into memory

Q83

Q83 When should SAX parsing be preferred over DOM?

A

When memory consumption is a concern

B

When XML needs frequent modifications

C

When searching for a specific node

D

When working with small XML files

Q84

Q84 What is a drawback of SAX parsing?

A

It is slower than DOM

B

It does not support event handling

C

It cannot modify XML while parsing

D

It requires loading the entire document into memory

Q85

Q85 Which of the following correctly initializes an XML parser in Python using DOM?

A

xml.dom.parse("file.xml")

B

xml.sax.parse("file.xml")

C

xml.etree.ElementTree("file.xml")

D

xml.parser.load("file.xml")

Q86

Q86 In Java, which class is used to parse an XML file using DOM?

A

SAXParserFactory

B

DocumentBuilderFactory

C

JsonParser

D

XMLReader

Q87

Q87 Which of the following methods is used to register a handler in SAX parsing?

A

setHandler()

B

registerHandler()

C

setContentHandler()

D

setXMLHandler()

Q88

Q88 What is the output of the following Java SAX parser snippet?
startElement("bookstore", "book", "book", attributes)

A

The start of the XML document

B

The start of a book element

C

The end of the XML document

D

The end of a book element

Q89

Q89 Why does a DOM parser consume more memory than SAX?

A

It processes XML line by line

B

It loads the entire XML file into memory

C

It cannot handle large XML files

D

It requires a network connection

Q90

Q90 A SAX parser throws an error while processing an XML file. What is the likely cause?

A

The XML file is too small

B

The XML file has an invalid structure

C

SAX does not support XML parsing

D

The XML document is missing comments

ad verticalad vertical
ad