I’m appending to a serializer in a loop, however having problems placing a root element.
Using this code:
serializer = serializer.startTag(null, StaticClass.ROOT);
for (int i = 0; i < categoriesCursor.getCount(); i++) {
appendToCategoriesXml(serializer, id, name, kind, uses);
categoriesCursor.moveToNext();
}
I don’t understand why the root being put automatically right after first list element, which looks like this:
<?xml version='1.0' encoding='UTF-8' standalone='yes' ?>
<root>
<category id="1">
<name>fun</name>
<kind>exp</kind>
<uses>0</uses>
</category>
</root>
<category id="2">
<name>food</name>
<kind>exp</kind>
<uses>15</uses>
</category>
What am I doing wrong?
I just discovered the problem… it was stupid. I did EndDocument at every iteration, so it ended root right after first one…