Summary
XML documents are text. This means that you can create an XML document using any technique you would normally use to create text files—including but not limited to output streams, writers, toString() methods, char arrays, or anything else that produces text. When you do this, you're responsible for maintaining well-formedness and validity. But, doing this is not hard, certainly no harder than debugging any other part of a program, and often considerably easier.
Because XML documents are text, it's best to use a Writer rather than an OutputStream to generate an XML document. However, because the Writer class has no standard method of determining what encoding it's using, you should normally build your Writer from an OutputStream you control, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access