@Override public void init(XmlPullParser parser) throws IOException, XmlPullParserException { parser.require(XmlPullParser.START_TAG, null, null); setCount(XppUtils.getAttributeValueAsLongFromNode(parser, "count")); setStart(XppUtils.getAttributeValueAsLongFromNode(parser, "start")); setTotal(XppUtils.getAttributeValueAsLongFromNode(parser, "total")); while (parser.nextTag() == XmlPullParser.START_TAG) { String name = parser.getName(); if (name.equals("product")) { ProductImpl node = new ProductImpl(); node.init(parser); getProductList().add(node); } else { // Consume something we don't understand. LOG.warning("Found tag that we don't recognize: " + name); XppUtils.skipSubTree(parser); } } }
@Override public void toXml(XmlSerializer serializer) throws IOException { XmlSerializer element = serializer.startTag(null, "products"); XppUtils.setAttributeValueToNode(element, "count", getCount()); XppUtils.setAttributeValueToNode(element, "start", getStart()); XppUtils.setAttributeValueToNode(element, "total", getTotal()); for (Product node : getProductList()) { ((ProductImpl) node).toXml(serializer); } serializer.endTag(null, "products"); }