XmlParser is a wrapper for org.xmlpull.v1.XmlPullParser, which allows to load structured data from XML.
XmlParser parser = new XmlParser(getResources().getXML(R.xml.something), factory)
XmlParser parser = new XmlParser(this, R.xml.something, factory)
factory
here is an object, that implements TagAcceptorFactory
interface. You can use HashMapFactory
,
which generates HashMapTags with public name
, params
, nested
tags and value
(see XmlParserTest
for examples).
HashMapFactory
is easy in use, but don't do any real work for you. The better idea is to use your common tag acceptors, generated by your own factory.
There are different ways to make your own tag acceptors. First of all, you can simply implement TagAcceptor
, but it's interface could be changed in few time.
Better way is to extend abstract SimpleTagAcceptor
or TagAcceptorWithDictionaryParams
. You also can suggest another abstract classes which you found to be usefull
Custom factory usage example could be found in CustomFactoryTest