Jibx - how to unmarshal/marshal tag with value and attribute?

只谈情不闲聊 提交于 2019-12-03 16:39:23

Use <value/> element twice in your binding. Once with attribute and once with text styles.

For example - to bind the following StateData class to the XML you want...

public class StateData {
  String name;
  String value;
}

...use the binding below:

<binding>
  <mapping name="stateData" class="StateData">
    <structure name="MyTag">
      <value style="attribute" name="name" field="name"/>
      <value style="text" field="value"/>
    </structure>
  </mapping>
</binding>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!