Check a Training XML Feed for Well-Formed Structure
Use XML Validator and Formatter on a fictional catalog snippet, distinguishing well-formedness warnings from schema validation.
By DevSphere Editorial · · 5 min read
Open XML ToolsAsk a syntax question, not a schema question
XML Validator can help identify malformed markup in a small document, but its label should not be mistaken for full data validation. The component parses the input with the browser's DOMParser, reports parse errors, and adds a few basic checks such as a missing XML declaration or possible unencoded ampersands. It does not load an XSD, DTD, or business schema. This tutorial uses a fictional workshop catalog with a root element, a couple of item elements, and one attribute. The purpose is to check balanced tags and inspect the tree, not to prove that a downstream import accepts the catalog. Keep identifiers synthetic and avoid copying actual customer or supplier documents. A document can be well-formed XML and still have the wrong fields, namespaces, or values for its intended application.
<?xml version="1.0" encoding="UTF-8"?>
<catalog>
<session code="LAB-1"><title>Sample Mapping</title><seats>12</seats></session>
<session code="LAB-2"><title>Demo Parsing</title><seats>8</seats></session>
</catalog>
Validate and read the document information
Open XML Tools and select Validator in the subtool navigation. Paste the sample into XML Input. The output should show XML is well-formed, identify catalog as the root element, and report element count and encoding when present. The validator may warn when an XML declaration is missing; here the declaration and UTF-8 encoding are included. Its checks are lightweight: an ampersand pattern may be reported as a possible warning, and malformed markup is reported through DOMParser diagnostics. Review the error and warning sections independently. A warning does not necessarily mean a parse failure, while no warning does not establish schema conformance. Namespaces, attributes, and element names must still be compared with the receiving system's contract. This browser-side check does not send the document to a server or retrieve a schema.
Inspect nesting in the tree
Choose Viewer or Parser to inspect a tree representation of the XML nodes. Viewer constructs a tree from the input; Parser displays its parsed tree as the selected output. Expand the catalog root and each session to confirm that code is an attribute and title and seats are child elements. The XML tree distinguishes element names, attributes, text, comments, and CDATA nodes. It is not an XPath query panel even if a catalog description mentions query capability. The displayed tree helps verify parent-child structure, but it does not enforce that every session has a unique code or a numeric seats value. For this sample expect two session elements, code attributes LAB-1 and LAB-2, and text values 12 and 8. XML text values remain text until an application interprets them. Do not infer a numeric data type solely from digits between tags.
Format for review without changing the contract
Select Formatter and choose an Indent value of two spaces for a compact review. The Preserve Comments checkbox controls whether comments are retained by the formatter. Click Load Sample only if you want the tool's built-in catalog example; otherwise keep the fictional input. Formatter uses a simple tokenization routine after parsing XML with DOMParser, then places tags and text on lines. It is intended for readability, not canonical XML output. Mixed content, namespaces, processing instructions, and complex CDATA arrangements deserve comparison with the original because token-based formatting can alter whitespace presentation. Do not minify or reformat signed XML and expect a cryptographic signature to remain valid. Copy Output is available for formatted results, but keep the original artifact intact whenever exact bytes, comments, or whitespace are meaningful.
<?xml version="1.0" encoding="UTF-8"?>
<catalog>
<session code="LAB-1">
<title>Sample Mapping</title>
<seats>12</seats>
</session>
<session code="LAB-2">
<title>Demo Parsing</title>
<seats>8</seats>
</session>
</catalog>
Troubleshoot and verify acceptance
If Validator reports an error, check that every start tag has a matching end tag, attributes are quoted, elements are properly nested, and ampersands in text are escaped. A message for a mismatched tag may point to a later line, so inspect the surrounding structure. Once the document parses, verify the root and both session branches in the tree. Then run the actual schema validator or import process if the document is destined for a system with stricter requirements. XML Tools does not check required fields, numeric ranges, allowed enumerations, namespace binding policy, or external schema references. If the output seems inconsistent, compare it directly with the XML Input text and do not rely on the formatter to fix semantic problems. Clear the workspace before another document. Use training-only content here and follow secure handling rules for real XML exports.
A malformed ampersand can make the browser parser and the extra warning check appear to disagree. In text, write an entity such as & instead of a bare ampersand; in an attribute, quote the complete value and escape markup characters as required. A possible-ampersand warning is not the same as a failed XML parse, so inspect both the well-formed status and the warning list. Likewise, a clean status only says that the document is parseable at this level. If an importer expects particular element order or namespaces, validate against its schema and a representative message. Keep the two activities separate: first fix XML syntax, then check application rules. That distinction makes a small diagnostic report more useful to the document owner.
When the viewer shows a root and element count, compare that summary with the sample rather than treating it as proof of completeness. The example has catalog as the only root and two session elements, each with a title and seats child. Attribute code values are not counted as child elements, so inspect them directly in the tree. If a namespace is introduced in a real document, verify both the prefix declaration and the URI expected by the receiving application. The simple information panel reports a namespace count but does not judge whether the vocabulary is correct. Save any findings as path-specific notes, then use an XSD-aware validator for formal acceptance.