我有被註釋爲XMLType的提取XML譜寫的Java
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "fooClass", propOrder = {
"fooElement1",
"fooElement2"
})
public class fooClass{
@XmlElement(required = true)
protected String fooElement1;
@XmlElement(required = true)
protected String fooElement2;
.....
}
我希望能夠提取XML表示的Java類(最好爲流,但字符串是OK以及)在Java中,沿線的東西:
fooClass foo = new fooClass()
foo.setFooElement1("baba")
foo.setFooElement2("abab")
String xmlRep = DomSomething(foo)
任何想法該怎麼辦?
謝謝!
你或許應該創建一個JAXB背景下,看到這一點:http://www.mkyong.com/java/jaxb-hello-world-example/ – BretC 2015-02-05 16:54:59