XML
解析を使用して以下をSimpleXML
解析しようとしています。
を解析するためにさまざまな方法を試しましAttributes
たElement
が、以下の XML の解析に成功しませんでした。
下部にリストされているエラーが生成されます。
<prestashop xmlns:xlink="http://www.w3.org/1999/xlink">
<order>
<id>1</id>
<id_address_delivery xlink:href="http://abc.com/add/1">1</id_address_delivery>
<id_address_invoice xlink:href="http://abc.com/add/2">2</id_address_invoice>
</order>
</prestashop>
Order.java
@Root(name="order")
@Namespace(reference="http://www.w3.org/1999/xlink",prefix="xlink")
public class Order {
@Element(name="id",required=true)
private int order_id;
@Element(name="id_address_delivery",required=false)
private int id_address_delivery;
@Attribute( name="href", required=false)
private String id_address_delivery_href;
@Element(name="id_address_invoice",required=false)
private int id_address_invoice;
@Attribute(name="href", required=false)
private String id_address_invoice_href;
}
OrderObject.java
public class OrderObject
{
@ElementList(required=true, inline=true)
private List<Order> list = new ArrayList<Order>();
public List<Order>getList()
{
return this.list;
}
}
私が得る例外は次のとおりです。
WARN/System.err(988): org.simpleframework.xml.core.PersistenceException:
Duplicate annotation of name 'href' on field 'id_address_delivery_href'
private java.lang.String com.prestashop.orders.Order.id_address_delivery_href
at org.simpleframework.xml.core.StructureBuilder.process(StructureBuilder.java:250)
at org.simpleframework.xml.core.StructureBuilder.process(StructureBuilder.java:173)
at org.simpleframework.xml.core.ObjectScanner.field(ObjectScanner.java:438)
at org.simpleframework.xml.core.ObjectScanner.scan(ObjectScanner.java:371)
at org.simpleframework.xml.core.ObjectScanner.<init>(ObjectScanner.java:82)
.
.