I have the below class. When Marshalling, I would like to omit the tag "config", is it possible?
@XmlRootElement(name = "config")
@XmlAccessorType(XmlAccessType.FIELD)
public static class Config {
@XmlElement(name = "dry-run")
protected Boolean dryRun;
@XmlElementWrapper(name = "filters")
@XmlElement(name = "filter")
protected List<String> filters;
public Boolean isDryRun() {
return dryRun;
}
public void setDryRun(boolean dryRun) {
this.dryRun = dryRun;
}
public List<String> getFilters() {
return filters;
}
}
Example:
Current output:
<Root>
<config xmlns:wf="nspace">
<dry-run>false</dry-run>
<filters>
<filter>
myFilter
</filter>
</filters>
</config>
</Root>
Desired output:
<Root>
<dry-run>false</dry-run>
<filters>
<filter>
myFilter
</filter>
</filters>
</Root>
UPDATE:
all I wanted to know is "can it be done ONLY with JAXB or not?". Just check this question (not the answer), I didn't get how he marshelled with only JAXB and no root element was written. It is precisely what I want.