FormattersLesson 11Free preview
XML Formatter
This lesson is part of Web Developer Tools · All levels
Summary
XML Formatter arranges XML elements with tiered indentations so that parent-child relationships are easily seen. Each child element is usually placed on its own line, and the attribute is refined into one line. XML has to be well-formed, which means that every opener tag has the right closing, before it can be formatted properly. For elements that mix text and tags, adding white space is a cautionary tale because it can affect the content of the text.
Key points
- Making a layered indentation for the nested elements
- Empty elements can be written in a self-closing form such as <tag/>
- XML must be well-formed before formatting
- Attributes are refined without changing their value
- Mixed content is sensitive to white space so it needs to be checked.
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.