XML interview question · Most asked

Explain XML namespaces and the default namespace.

Create a free account to save this page, take notes and track your progress. Sign in

Summary

A namespace gives element and attribute names a globally unique identity: a URI plus a local name. xmlns:p="uri" binds a prefix; xmlns="uri" sets a default namespace for unprefixed elements in scope. Prefixes are just shorthand: two documents with different prefixes for the same URI mean the same thing. Unprefixed attributes are in no namespace.

Longer Answer

The URI is an identifier, not a download location. In code, names are often written in Clark notation, {uri}local.

Key Points

  • Name = URI + local name.
  • Prefix binding vs default namespace.
  • Prefixes don't matter, URIs do.
  • Unprefixed attributes: no namespace.

Deep dive: XML Tutorial: XML Namespaces

Explanation

What interviewers look for

The default-namespace and attribute subtleties.

More most-asked XML questions

← All XML questions

Was this page helpful?