質問

i have a class like this:

@XmlAccessorType(XmlAccessType.PROPERTY)
@XmlRootElement(name="someClass")
public class SomeClass implements Serializable {
    [...]
    @XmlElement(name="field")
    public String getSomeField() {
        return field;
    }
    [...]
}

The resulting XML after marshaling is, rightfully:

<someClass>
    <field>blablacontent</field>
</someClass>

I now want the content of "field" be the content of the someClass element directly, like this:

<someClass>
    blablacontent
</someClass>

I've looked around a lot what the annotations can do, i didn't find anything. Is this not possible ? Thanks very much for any advice !

役に立ちましたか?

解決

If you have no other @XmlElement annotated properties in your class, you can use @XmlValue.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top