toXml() fails on a specific XML structure

When XML looks like
`<blah attr="1"><attr value="2"></attr></blah>`
then it parses to something like
`{blah: {attr: [1, {value: 2}]}`
and `toXml()` fails on `Object.keys()` for `1`.