33 chars · 1 line
Waiting for input
33 chars · 1 line
Waiting for input
XML document-root troubleshooting
The sample contains name and port as separate top-level elements. XML documents need one document element that contains the rest of the element tree, so independent fragments must be wrapped or handled as separate documents. This tool is free to use. No account or payment is required.
Last updated
Two well-formed element fragments can still be invalid when concatenated as one XML document. A document parser expects one document element around all ordinary element content.
A wrapper changes the document shape. For APIs, feeds, or message streams, confirm the expected envelope before adding a new root element solely to satisfy syntax validation.
Wrap related fields in one service root element.
<name>api</name><port>8080</port><service><name>api</name><port>8080</port></service>Common questions
A well-formed XML document has exactly one document element.
Comments and some processing instructions can appear outside the document element, but a second ordinary top-level element cannot become another root.
Only when those fragments are intended to form one document. Separate protocol messages should usually remain separate.
Debugging a specific XML issue? Browse XML troubleshooting.