Interview Q&A · questions with model answers

XML Interview Questions

Ordered by how often they're asked. Most-asked answers are free to read in full; members see every answer and can rate their confidence on each.

  1. Most asked Explain XML namespaces and the default namespace.

    An XML namespace pairs a URI with element and attribute names to give them globally unique identities, preventing name collisions when combining vocabularies. A prefix binding (xmlns:p="uri")…

  2. Most asked Explain XPath axes and give examples of predicates.

    XPath axes define the direction of navigation from the context node: child (default), attribute (@), descendant (//), parent (..), ancestor, following-sibling, preceding-sibling, following,…

  3. Most asked How does XSLT work? Explain templates and apply-templates.

    XSLT (XSL Transformations) is a declarative language for transforming XML documents. A stylesheet contains template rules that match nodes by XPath patterns. The processor starts at the document…

  4. Most asked XML, JSON or YAML: how do you choose?

    Choose JSON for web and mobile APIs — it maps directly to JavaScript objects, is smaller on the wire, and is universally supported. Choose YAML (or TOML) for human-edited configuration files — it is…

  5. Explain the main building blocks of an XML Schema.

    An XML Schema (XSD) is built from element and attribute declarations with types: simple types for text values (restricted with facets like pattern, enumeration, minInclusive), complex types for…

  6. How do character encodings work in XML, and what causes mojibake?

    The XML declaration's encoding attribute (defaulting to UTF-8) tells the parser how to decode the file's bytes into characters. Mojibake — garbled text like "Müller" instead of "Müller" — occurs…

  7. How do you work with XML in the browser and in Node.js?

    Browsers provide built-in XML support: DOMParser to parse XML strings into a DOM tree, XMLSerializer to convert back to a string, document.evaluate() for XPath 1.0 queries, and XSLTProcessor for…

Was this page helpful?

Report a mistake