Thursday, December 23, 2010

[android-developers] XmlSerializer issue

I have the following 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
}

The problem is that the serializer fails to serialize/write
everything. What could be possible reason? Any pointer would be
greatly appreciated.

Thank you in advance.

Rex

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment