protected void readElement(XmlSerializer out, boolean includeOuterTag) throws XmlParseException, XmlPullParserException, IOException { XmlPullParser in = getParser(); if (in.getEventType() != START_TAG) { throw new XmlParseException(in, "start tag expected"); } if (out != null && includeOuterTag) { out.startTag(in.getNamespace(), in.getName()); } int depth = 1; while (depth != 0) { switch (in.next()) { case START_TAG: if (out != null) { out.setPrefix("", in.getNamespace()); out.startTag(in.getNamespace(), in.getName()); for (int i = 0; i < in.getAttributeCount(); i++) { String attributeNamespace = in.getAttributeNamespace(i); String attributeName = in.getAttributeName(i); String attributeValue = in.getAttributeValue(i); out.attribute(attributeNamespace, attributeName, attributeValue); } } depth++; break; case END_TAG: if (out != null && (includeOuterTag || depth > 1)) { out.endTag(in.getNamespace(), in.getName()); } depth--; break; case TEXT: if (out != null) { out.text(in.getText()); } break; case CDSECT: if (out != null) { out.cdsect(in.getText()); } break; case ENTITY_REF: if (out != null) { out.entityRef(in.getText()); } break; } } if (out != null) { out.flush(); } }