Android XmlSerializer limitation?
- by Rexb
Hi all,
My task is just to get an xml string using XmlSerializer. Problem is that it seems like the serializer stops adding any new element and/or attribute to the xml document when it reaches certain length (perhaps 10,000 char?).
My questions: have you experience this kind of problem? What could be possible solutions?
Here is my sample test code:
public void doSerialize() throws XmlPullParserException, IllegalArgumentException, IllegalStateException, IOException {
StringWriter writer = new StringWriter();
XmlSerializer serializer = XmlPullParserFactory.newInstance().newSerializer();
serializer.setOutput(writer);
serializer.startDocument(null, null);
serializer.startTag(null, "START");
for (int i = 0; i < 20; i++) {
serializer.attribute(null, "ATTR" + i, "VAL " + i);
}
serializer.startTag(null, "DATA");
for (int i = 0; i < 500; i++) {
serializer.attribute(null, "attr" + i, "value " + i);
}
serializer.endTag(null, "DATA");
serializer.endTag(null, "START");
serializer.endDocument();
String xml = writer.toString(); // value: until 493rd attribute
int n = xml.length(); // value: 10125
}
Any help will be greatly appreciated.