Formatting
XML formatter checks that the document is well formed, requires exactly one root element, and reprints it with a two-space indent. <note><to>Sam</to><body>Hi</body></note> becomes a note element with to and body nested inside. Attribute order and text are kept. Values are not retyped as numbers, so a text node 02 stays 02.
A document type declaration is refused. Formatting a DTD would mean expanding entities and pulling in declarations this page will not fetch. More than one root is an error, because an XML document has one. Mixed content, text and child elements in the same parent, is not given extra whitespace between inline tags, so a sentence with an <em> in the middle does not grow spaces that change the text a reader sees.
The validator is the page that stops at “Valid XML” and does not reprint. Both report the line and column when the parse fails. Pasting Odd socks in the dryer. fails at line 1, column 1, because the character O is not the start of a tag.
<note><to>Sam</to><body>Hi</body></note>
<note>\n <to>Sam</to>\n <body>Hi</body>\n</note>
Mixed content stays tight. Indenting inside a sentence would change “Hello <em>there</em>” into something with different spaces.
The formatter expects a tag. Odd socks in the dryer. fails at line 1, column 1, because O is not a legal start. Wrap text in an element if it is supposed to be XML.
No. DTDs are refused so the page does not resolve entities from a declaration. The validator also checks well-formedness and still will not fetch external markup.
That is an error. An XML document has one root. Wrap them if you need both.
No. Tag text is kept as text. 02 stays 02.