Мне нужно прочитать и написать документ XML, например:
<connections>
<connection>
<operation>add</operation>
<node>A01</node>
<interface>AIF01</interface>
<node>B01</node>
<interface>BIF01</interface>
</connection>
<connection>
<operation>delete</operation>
<node>A02</node>
<interface>AIF02</interface>
<node>B02</node>
<interface>BIF02</interface>
</connection>
Так что теги <node>
и <interface>
должны быть сопоставлены с различными полями. Маршаллинг такого объекта работает нормально, но демаршаллинг не работает для меня.
<connections>
собираются:
@XmlElement(name = "connection")
List<Connection> connections;
Определение connection
:
@XmlAccessorType(XmlAccessType.FIELD)
public class Connection {
@XmlElement(name = "operation")
private Operation operation;
@XmlElement(name = "node")
private String sourceNode;
@XmlElement(name = "interface")
private String sourceInterface;
@XmlElement(name = "node")
private String targetNode;
@XmlElement(name = "interface")
private String targetInterface;
}
Итак, когда я отменяю такой xml файл, targetNode
и targetInterface
равны нулю, потому что он сопоставлен с source*
полями.
Может кто-нибудь помочь? Заранее спасибо.