title: How to convert data part of an object into XML using XStream?
body: <p>First of all, I'm sorry if the question is not clear. I'm trying to create an XML out of an object with its content in it using XStream.</p>
  
  <p>Following is the form of XML I'm trying to achieve: </p>
  
  <pre><code>&lt;Tag attr1 = "some_value" attr2 = "some_value"&gt; CONTENT &lt;/Tag&gt;
  </code></pre>
  
  <p>I'm having trouble designing the class. </p>
  
  <p>Following is how I have implemented it so far: </p>
  
  <pre><code>@XStreamAlias("Tag")
  public class Tag {
  
    @XStreamAsAttribute
    private String attr1;
  
    @XStreamAsAttribute
    private String attr2;
  
    private String content;
  
    public Tag(String content) {
  
      this.content = content;
    }
  
    // Getters for all three
  
    // Setters for all three
  }
  </code></pre>
  
  <p>Now when I do the following:</p>
  
  <pre><code>Tag tag = new Tag("Content");
  tag.setAttr1("some_value");
  tag.setAttr2("some_value");
  XStream xStream = new XStream();
  xStream.processAnnoations(Tag.class);
  System.out.println(xStream.toXML(tag));
  </code></pre>
  
  <p>I get the XML with an extra <code>&lt;content&gt;</code> tag. I don't want the extra <code>&lt;content&gt;</code> tag, I want it to be the content of <code>&lt;Tag&gt;</code>. How do I do that using XStream?</p>