Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p><strong>Note:</strong> I'm the <a href="http://www.eclipse.org/eclipselink/moxy.php" rel="nofollow noreferrer">EclipseLink JAXB (MOXy)</a> lead, and a member of the JAXB (<a href="http://jcp.org/en/jsr/detail?id=222" rel="nofollow noreferrer">JSR-222</a>) expert group.</p> <hr/> <p>I believe the answer is:</p> <pre><code>@XStreamImplicit(itemFieldName="outline") private List&lt;OutlineItem&gt; childItems; </code></pre> <p>Have you considered using a JAXB implementation (<a href="http://jaxb.java.net/" rel="nofollow noreferrer">Metro</a>, <a href="http://www.eclipse.org/eclipselink/moxy.php" rel="nofollow noreferrer">MOXy</a>, <a href="http://ws.apache.org/jaxme/" rel="nofollow noreferrer">JaxMe</a>, ...) instead?</p> <ul> <li><a href="https://stackoverflow.com/questions/6159047/modern-alternative-to-java-xstream-library/6161183#6161183">Modern alternative to Java XStream library?</a></li> <li><a href="http://bdoughan.blogspot.com/2010/10/how-does-jaxb-compare-to-xstream.html" rel="nofollow noreferrer">http://bdoughan.blogspot.com/2010/10/how-does-jaxb-compare-to-xstream.html</a></li> </ul> <p><strong>OutlineItem</strong></p> <pre><code>import javax.xml.bind.annotation.*; @XmlRootElement(name="outline") @XmlAccessorType(XmlAccessType.FIELD) public class OutlineItem implements java.io.Serializable { private static final long serialVersionUID = -2321669186524783800L; @XmlAttribute private String text; @XmlElement("outline") private List&lt;OutlineItem&gt; childItems; } </code></pre> <p><strong>Demo</strong></p> <pre><code>import javax.xml.bind.*; public class Demo { public static void main(String[] args) throws JAXBException { JAXBContext jaxbContext = JAXBContext.newInstance(OutlineItem.class); Marshaller marshaller = jaxbContext.createMarshaller(); marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); marshaller.marshal(outlineItem, System.out); } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload