Usage of Synder is straightforward. Both parsing and generating require a Context, which you must construct.
Default context implementations are provided for you.
Parsing requires a SAX2 implementation, or optionally an XML Pull implementation. The parsing context allows you to specify how the SAX2 parser is constructed and configured.
Default implementations are provided for you. By default, Synder uses the parser produced by javax.xml.parsers.SAXParserFactory.newInstance().
final InputStream px = new FileInputStream(PROPERTIES); final Context ctx = new DefaultContext(px); final InputStream ss = new FileInputStream(INPUT); final DefaultParseContext dpc = new DefaultParseContext(ctx); final SyndFeed sf = dpc.parse(new InputSource(ss));
Generating requires an XML Pull implementation, e.g. XPP3. The generator context allows you to specify how the XmlSerializer is constructed and configured.
Default implementations are provided for you. By default, Synder uses the serializer produced by org.xmlpull.v1.XmlPullParserFactory.newSerializer().
final SyndFeed sf = ... final InputStream px = new FileInputStream(PROPERTIES); final Context ctx = new DefaultContext(px); final DefaultGenerateContext dgc = new DefaultGenerateContext(ctx, new GenerateXmlPull()); dgc.generate(sf, sf.getFeedType(), new FileOutputStream(OUTPUT), "UTF-8");