XML内容如下:
<RichContent>
<Para>This is Paragraph 1
<LineBreak/>
<Strong>This is Strong html tag in Para1. </Strong> Something else...
</Para>
<Para>This is Paragraph 2
<LineBreak/>
<Strong>This is Strong html tag in Para2. </Strong> Something else...
</Para>
<Para>This is Paragraph 3
<LineBreak/>
<Strong>This is Strong html tag in Para3. </Strong> Something else...
</Para>
</RichContent>
解析类是:
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "RichContent", propOrder = {
"para"
})
public class RichContent {
@XmlElement(name = "Para")
protected List<Para> para;
// getter & setter
}
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "Para", propOrder = {
"content"
})
public static class Para {
@XmlMixed
protected List<String> content;
public String getContent() {
String result = "";
for(String cnt : content) {
result += cnt;
}
return result;
}
public void setContent(List<String> content) {
this.content = content;
}
}
我使用注释&#34; @ XmlMixed&#34;,&#34; LineBreak&#34;设置内容。我希望消失,但问题是,&#34;强&#34;之间的内容。和&#34; /强&#34;也消失了。
有人可以帮我处理吗?谢谢!