Fix XML length encoding