XML workflow

XML formatting: well-formedness, whitespace and validation

Format a disposable XML sample to read its structure. Keep the original whenever exact bytes, signatures or text spacing matter.

Content updated: · Maintained by Hung Chi-Hsueh · corrections

Well-formed is a syntax result

XML needs one root element, properly nested case-sensitive tags and quoted attributes. A bare ampersand in text must be escaped as &. A browser parser can detect these syntax errors.

An XML validator may also check a DTD or XSD schema: allowed elements, required fields and data types. This tool performs only the first step. It does not check business rules or establish trust.

Whitespace can be content

In <p>Hello <b>world</b>!</p>, inserting line breaks changes text nodes. CDATA and xml:space="preserve" also signal that automatic whitespace changes are inappropriate. The tool keeps the whole original when it finds any of these cases.

Without a schema, even whitespace between elements may matter to your consumer. Review formatted output against the receiving application. XMLSerializer may change quotes, namespace declarations, empty tags and the XML declaration; this is not XML canonicalization.

Query with explicit XPath namespaces

The XPath Tester uses native browser XPath 1.0, not XPath 2.0/3.1 or XSLT. With <root xmlns="urn:example"><item>value</item></root>, map e=urn:example and query /e:root/e:item. /root/item matches only elements without a namespace; a default XML namespace does not become an XPath default namespace.

Nodes displays escaped XML, Values displays XPath text values, and Paths produces prefix-independent expressions. A document root's string value is its descendant text, not an empty DOM textContent. Copyable paths can exceed this tool's 1,024-character expression limit; test longer paths in a suitable environment. Namespace-axis nodes are explicitly unsupported.

The query tool accepts 100 KiB, 2,000 nodes including attributes, 100 levels and at most 4 Mi characters of complete output. Native evaluation is synchronous and cannot be cancelled; avoid costly expressions. XML is never inserted into the active page or used to fetch resources. A match is not schema validation.

Choose the XML records to turn into CSV rows

For a feed with both meta and item elements directly under feed, choose /feed/item. Each item becomes one row, while meta elements and root attributes stay outside the export. With <item id="001"><name>Tea</name></item>, the columns are attr.id and field.name. Columns appearing only in later records are included. Missing fields and empty values both become empty cells.

Use namespace-free XML 1.0 with flat records. Nested, repeated or attributed fields and mixed content in the selected records need a deliberate mapping before conversion. The tool blocks formula-like values, including negative numbers, rather than changing them. CSV quoting handles separators and line breaks but does not control spreadsheet type detection. Import identifiers as text to preserve leading zeroes.

The converter accepts up to 100 KiB of UTF-8, 2,000 nodes including attributes, 32 levels, 500 selected records, 64 columns and 512 KiB of output. Preview shows up to 20 rows, and the downloaded CSV includes every selected row.

Local processing and limits

Input is parsed as XML 1.0 in memory and displayed only as plain text. There is no document upload, URL fetch or input storage. DOCTYPE, ENTITY and xml-stylesheet declarations are rejected, including matching strings inside comments or CDATA.

Limits are 512 KiB input, 10,000 nodes, 100 levels and 2 MiB output. Browser diagnostic wording differs. For DTD, XSD, signatures or larger documents, use your project's approved XML toolchain with an explicit external-resource policy.

Example
<root><item id="demo">Hello &amp; welcome</item></root>

<!-- Preserve mixed content: -->
<p>Hello <b>world</b>!</p>

Data provenance

Sources