Android XmlSerializer limitation?
Posted
by
Rexb
on Stack Overflow
See other posts from Stack Overflow
or by Rexb
Published on 2010-12-23T04:49:02Z
Indexed on
2010/12/23
4:54 UTC
Read the original article
Hit count: 274
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.
© Stack Overflow or respective owner