<Mall>
<ProductInfo>
<Product>
<name>chair</name>
<price>150</price>
</Product>
</ProductInfo>
</Mall>
To get this result, I made 3 java classes which are
XmlRootElement
, XmlElement
In this way, I could make only 3 depths using XmlRootElement
, XmlElement
, Component of product.
Hence I need one more depth.. I tried to use a XmlElementWrapper
to give one more depth, but there was an error regarding it is not a collecting attribute...
Please help me to solve this out...
Below is class structure that should work
@XmlRootElement (name = "mall")
public class Mall {
Mall(){ }
@XmlElement(name="ProductInfo")
private ProductInfo info; // must create getter and setter
}
}
public class ProductInfo { // you should be missing this
ProductInfo(){
}
@XmlElement(name="Product")
private List<Product> info; // must create getter and setter
}
}
public class Product {
Product(){
}
@XmlElement(name="name")
private ProductInfo info; // must create getter and setter
@XmlElement(name="price")
private ProductInfo info; // must create getter and setter
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.