I wrote a question that did not have much success: https://stackoverflow.com/questions/21296465/serialize-hashmap-as-xml-without-repeating-parent-elements . It seems to me that perhaps I was asking the wrong question.
Is there a built-in Android class for creating XML not continuously?
Continuously, I mean the ability to manipulate existing elements (add / remove child elements, etc.). So far I have found XML creation methods (XmlSerializer, build Strings), but only in a continuous document.
Here is the pseudo code for what I'm looking for:
[...]
xmldoc.startXML();
Element rootNode = xmldoc.addElement("object", "");
Element key1 = rootNode.addChildElement("key", "key1");
rootNode.addChildElement("value", "value1");
[...]
xmldoc.flush(handler);
With some additional logic, these functions can create the following XML
<object>
<key>root</key>
<object>
<key>key1</key>
<value>value1</value>
</object>
<object>
<key>key2</key>
<value>value2</value>
</object>
<object>
<key>ns</key>
<object>
<key>key3</key>
<value>value3</value>
</object>
<object>
<key>key4</key>
<value>value4</value>
</object>
</object>
</object>