XML Code Formatting
Formatting Standards
- Indent XML files using two spaces. Do not use tabs.
- Save all XML files with UTF-8 encoding.
- Ensure XML content uses UTF-8.
- Limit each line to a maximum of 120 characters. Wrap lines that exceed this limit.
- Review Eclipse XML auto-formatting settings, especially for line wrapping and binary data, to avoid formatting issues.
Example
<?xml version="1.0" encoding="UTF-8"?> <!-- My comment --> <person gender="male"> <fistname>John</firstname> <lastname>Doe</lastname> </person>
XML Formatting Tools
- On Linux, use xmlformat.sh to format XML files.