import java.io.File;
import java.util.List;
import java.util.Map;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.Marshaller;
import javax.xml.bind.Unmarshaller;
import javax.xml.bind.annotation.XmlAnyAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.namespace.QName;
@XmlRootElement(name = "Root")
class Root {
private Map extension;
private List cnodes;
@XmlAnyAttribute
public Map getExtension() {
return extension;
}
public void setExtension(Map extension) {
this.extension = extension;
}
@XmlElement(name = "CNode")
public List getCnodes() {
return cnodes;
}
public void setCnodes(List cnodes) {
this.cnodes = cnodes;
}
}
class Node {
private Map extension;
@XmlAnyAttribute
public Map getExtension() {
return extension;
}
public void setExtension(Map extension) {
this.extension = extension;
}
}
public class Main {
public static void main(String[] args) throws Exception {
JAXBContext jc = JAXBContext.newInstance(Root.class);
Unmarshaller unmarshaller = jc.createUnmarshaller();
Root root = (Root) unmarshaller.unmarshal(new File("input.xml"));
Marshaller marshaller = jc.createMarshaller();
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
marshaller.marshal(root, System.out);
}
}