It's a lightweight library for mapping arbitrary XML to your Java classes, mapped via annotations or external config, understands XML namespaces, can cache unmapped elements, preserves order of XML elements, it's extensible with custom converters, it's thread-safe and is lightweight at under 80kb with no external dependencies. Oh, and it has a permissive license: BSD.
List of features:
Let’s map some xml:
to this class:
@RootElement
public class Root {
@Attribute
public float a;
@Element
public Integer node;
@Text
public String text;
}
All you have to do is add @Element
, @Attribute
and @Text
annotations to your classes and configuration is done.
Mapping is than done in just two lines of code:
Xmappr xm = new Xmappr(Root.class);
Root root = (Root) xm.fromXML(reader);
If you don't like annotations you can configure mappings via XML configuration. For the given example it's:
<root-element name="root" class="package.name.Root">
<attribute field="a"/>
<element field="node"/>
<text field="text"/>
</root-element>
Now head on to documentation.