XML to YAML
Input
<config>
<host>localhost</host>
<ports><port>80</port><port>443</port></ports>
</config>Output
config:
host: localhost
ports:
port:
- 80
- 443The repeated <port> elements become a YAML sequence.
Attributes are prefixed with @_ so they stay distinct from elements.
Values with leading zeros stay strings so IDs are preserved.
Spaces per level of nesting.
XML to YAML trades angle brackets for indentation, which usually makes a document considerably shorter and easier to read, closing tags disappear entirely, and so do most quotes.
The mapping follows the same rules as XML to JSON, because both targets share one data model. The same caveat therefore applies: XML cannot distinguish a single item from a one-item list.
Each example below is executed against this tool by the test suite, so what you see is what the tool actually produces.
Input
<config>
<host>localhost</host>
<ports><port>80</port><port>443</port></ports>
</config>Output
config:
host: localhost
ports:
port:
- 80
- 443The repeated <port> elements become a YAML sequence.
The details that decide whether a conversion is correct, and where information can be lost without any error being raised.