XML interview question · Most asked

What's the difference between well-formed and valid XML?

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

Summary

Well-formed means the document follows XML syntax: one root, properly nested and closed tags, quoted attributes, escaped special characters. Valid means it's well-formed and also conforms to a schema (DTD, XSD, RELAX NG). A parser must reject malformed XML; validation is an extra, optional step.

Longer Answer

Every valid document is well-formed, but not vice versa. In integrations, validate at the boundary so bad messages fail with clear reasons instead of breaking later processing.

Key Points

  • Well-formed: syntax rules.
  • Valid: also matches a schema.
  • Malformed input is a fatal error.
  • Validate at system boundaries.

Deep dive: XML Tutorial: Well-Formed XML

Explanation

What interviewers look for

Clear distinction and why validation matters for integrations.

More most-asked XML questions

← All XML questions

Was this page helpful?