我使用Simple XML框架序列化了这个类。我没有得到我想要的xml结果

时间:2017-12-01 08:35:09

标签: java xml

是否可以使用普通标签而不是自动关闭标签?

xml class:

@Root(name = "testsimple")
public static class TestSimple{

    @Attribute(name = "id")
    private int clientId;

    @Attribute(name = "name")
    private String clientName;

    @Path("list")
    @ElementList(inline=true)
    private List<Feature> list;
} 

@Root(name = "ad")
public static class Feature{
    @Attribute(name = "id")
    private String id;

    @Attribute(name = "name")
    private String name;
}

预期结果:

<testsimple id="id" name="name">
    <list>
        <feature id="id" name="name"></feature>
        <feature id="id2" name="name2"></feature>
    </list>
</testsimple>

实际结果:

<testsimple id="id" name="name">
    <list>
        <feature id="id" name="name"/>
        <feature id="id2" name="name2"/>
    </list>
</testsimple>

0 个答案:

没有答案