嗨,我需要使用Jackson-dataformat XMLMapper从JAVA创建XML.
XML应该是这样的
1
Mighty Pulpo
austin
TX
Hong Kong
Hong Kong
但我总是喜欢额外的“< addresses>< / addresses>”标签.
1
Mighty Pulpo
austin
TX
Hong Kong
Hong Kong
我使用下面的代码来创建XML
JaxbAnnotationModule jaxbAnnotationModule = new JaxbAnnotationModule();
XmlMapper mapper = new XmlMapper();
mapper.enable(SerializationFeature.INDENT_OUTPUT);
mapper.registerModule(jaxbAnnotationModule);
mapper.registerModule(new GuavaModule());
String xml = mapper.writeValueAsString(customer);
System.out.println(xml);
有人可以帮帮我吗?如何删除额外的标签呢.我曾尝试使用@XmlElement,但它没有帮助. TIA!