Ho to use JAXB to unmarshall an empty tag element into the tag name instead of null?

I have an input XML file which uses empty tag to represent valid data. I cannot change this. The item material can be either “metal” or “plastic” as specified by empty tags and . The problem with JAXB is that it unmarshalls empty tags to empty strings. How can I use JAXB be so that I could extract and as tag names rather than their empty values? If there is no way to do it using JAXB, what parser should I use?

XML Input File

      <id>item 1<id>
      <id>item 2<id>

Java bean class for corresponding Java object.

@XmlRootElement(name = "items")
public class Items{
    private List<Item> items;

    public List<Item> getItems() {
        return items;

    @XmlElement(name = "item")
    public void setItes(List<Item> items) {
        this.items= items;

    public static class Item{

        private String        id;
        private String        material;

        public String getId() {
            return id;

        @XmlElement(name = "id")
        public void setId(String id) {
            this.id = id;

        public String getMaterial() {
                return material;

        public void setMaterial(String material) {
                this.material = material;

Controller class

public class ItemParser {

    public static void main(String[] args) {
    //  System.out.println("Hello World!");

        try {

            File file = new File("I:\items.xml");
            JAXBContext jaxbContext = JAXBContext.newInstance( Items.class );

            Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
            Items items = (Items) jaxbUnmarshaller.unmarshal( file );

          } catch (JAXBException e) {