@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "Item", propOrder = {
"code",
"name",
"price"
})
@XmlRootElement(name="inventory")
public class Item {
@XmlElement(name="catalog_num", required = true)
protected String code;
@XmlElement(name="catalog_descrip", required = true)
protected String name;
@XmlElement(name="prod_price")
protected double price;
public String getCode() {
return code;
}
JAXBContext databaseJC = JAXBContext.newInstance(Item.class);
Unmarshaller databaseUnmarshaller = databaseJC.createUnmarshaller();
File databaseXML = new File("src/forum6838882/database.xml");
Item item = (Item) databaseUnmarshaller.unmarshal(databaseXML);
我的问题是:
我怎样才能得到@XmlElement(name="catalog_num", required = true)
from item 对象。我需要知道name="catalog_num"
这里。