简体   繁体   中英

JAXB. How to annotate classes to get following XML?

I have xml file and I want to create set of classes based on it with JAXB annotations, which will be used to un-marshall XML files.

XML:

<widgetOutput>
<dataItems>
<dataItem><isLimit>false</isLimit></dataItem>
<dataItem><size>1000</size></dataItem>
<dataItem><key>Canada</key><value>1</value></dataItem>
<dataItem><key>US</key><value>2</value></dataItem>
<dataItem><key>Italy</key><value>3</value></dataItem>
<dataItem><key>France</key><value>4</value></dataItem>
...
<dataItem><key>some_N_key_here</key><value>some_N_value_here</value></dataItem>
<status>complete</status>
</dataItems>
</widgetOutput>

I can't modify this xml, it is being generated byt he web service. Please advise how classes along with annotations may look like. Thanks in advance.

考虑为预期的XML创建模式,并使用XJC为您创建Java类。

Use tools such as the ones provided by NetBeans to create all necessary classes from a WSDL file.

Or use a Maven plugin if you're using Maven.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM