Overview
Introduction
Some XML tooling insists on self-closing empty tags; other tooling chokes on them and wants an explicit open/close pair instead.
This tool converts a whole document to whichever style you need.
What Is XML Syntax Changer?
A style-normalizing tool that walks a parsed XML document.
It rewrites every empty element consistently, as either self-closing or an explicit open/close pair, based on the mode you choose.
How XML Syntax Changer Works
The document is parsed and re-serialized.
At each empty element, self-closing already, or with no meaningful content, the chosen style is applied, while elements with actual content are left structurally unchanged (just re-indented).
When To Use XML Syntax Changer
Use it when a downstream parser or schema tool requires one specific empty-element style.
It handles a source document that uses the other style, or a mix of both, in one pass.
Often used alongside XML Double Quote Converter, XML Single Quote Converter and XML Prettifier.
Features
Advantages
- Standardizes style across an entire document in one pass.
- Leaves elements with actual content untouched.
- Runs entirely client-side.
Limitations
- Only affects empty elements, this isn't a general reformatter, use the XML Prettifier for indentation on elements with content.
- Applies one style to the whole document, there's no way to mix styles for different elements in a single pass.
Examples
Best Practices & Notes
Best Practices
- Run the XML Validator after switching styles if you're unsure whether the target system also cares about other formatting details.
- Pick self-closing for more compact output, or open/close for compatibility with stricter parsers.
- Re-run after merging XML from multiple sources, to standardize whatever mix of styles they arrived with.
Developer Notes
Both modes share one recursive renderer in `change-xml-syntax.ts`; the `mode` parameter only changes how the two lines handling empty elements are serialized.
XML Syntax Changer Use Cases
- Matching a downstream parser's expected empty-element style
- Standardizing style across a document assembled from multiple sources
- Cleaning up style before a code review or commit
Common Mistakes
- Expecting this to reformat elements with content beyond re-indenting them, use the XML Prettifier for general formatting.
- Assuming a single element can keep a different style from the rest, the mode applies document-wide.
Tips
- Pick collapse-to-self-closing for more compact output, or expand for compatibility with stricter parsers.
- Check the FAQ above if the output doesn't look like what you expected.