This format is always trouble for reverse engeneering. When there are question about binary XML, the usual answer is "use apktool" (or something similar).
However, no tool is perfect; actually all suggested tools are more or less buggy, and I don't know tool that can successfully decompile and recompile any APK from Google Play.
Because such tools are usually open source ones, they are rarely updated and don't fix bugs for years (see Issues on github for any such tool and see how quickly issues are closed).
My question is: so, where is this format documented? If
apktool and similar tools exists, it mean that they found format description somewhere and tried to implement its parser and writer.