YAML 到 XML 转换器
指导
YAML 到 XML 转换器
Convert YAML to well-formed XML instantly. Paste your YAML content and get properly structured XML output with configurable options for array handling, null values, indentation, and XML declaration. Includes reverse XML-to-YAML conversion, validation with error reporting, and a reference guide for mapping rules.
如何使用
Paste YAML into the input area or load a sample. Configure the root element name, array handling style (repeated elements or indexed), indentation, null handling, and whether to include an XML declaration. The converter instantly produces well-formed XML output. Copy to clipboard or download as .xml file. Use reverse mode to convert XML back to YAML. The validation section shows any parse errors with line numbers.
特征
- 即时转换 — Paste YAML and get well-formed XML immediately. Handles nested objects, arrays, strings, numbers, booleans, and null values with proper type mapping.
- 数组处理 — Choose between repeated elements (each array item gets a singularized parent tag name) or wrapped elements with index suffixes. Configurable to match your XML schema requirements.
- XML 声明 — Optionally include the standard XML declaration header with version and encoding attributes.
- Null 处理 — Configure how YAML null values map to XML: self-closing empty elements, xsi:nil attribute, or omit null elements entirely.
- CDATA Support — Optionally wrap string values in CDATA sections to preserve special characters without entity escaping.
- Reverse Mode — Convert XML back to YAML using the browser’s built-in DOMParser. Paste XML and get clean YAML output.
- 验证 — Detects invalid YAML with error messages and line numbers. Warns about YAML features that don’t map cleanly to XML (mixed-type arrays, complex keys).
- Tag Name Sanitization — Automatically sanitizes YAML keys that aren’t valid XML tag names: replaces spaces with underscores, prefixes number-starting keys, removes invalid characters.
YAML to XML Mapping
YAML objects become nested XML elements: each key becomes a tag name, and values become either text content (for primitives) or child elements (for objects/arrays). Arrays require a mapping choice since XML has no native array concept — items can be repeated elements with a singularized name or wrapped with index suffixes. Booleans map to “true”/”false” text, numbers retain their string representation, and null values map to self-closing tags or xsi:nil attributes.
