XStream : node with attributes and text node?

后端 未结 4 785
难免孤独
难免孤独 2020-12-09 03:59

I would like to serialize an object to an XML of this form with XStream.

text

The value of the node

4条回答
  •  温柔的废话
    2020-12-09 04:34

    Just another way of doing it:

       @XStreamAlias("My")
       private static class My {
          private String field;
       }
    
       XStream xStream = new XStream();
       xStream.autodetectAnnotations(true);
       xStream.useAttributeFor(My.class, "field");
    

提交回复
热议问题