XML 構造:
<rep>
<text type="full">[!CDATA[Demo, <a href="http://www.google.com" target="_blank">Search</a> thank you]]</text>
</rep>
JAXB を使用してこの XML を解析することはできますが、結果は安っぽく、@XmlValue
テキスト要素の値を取得するために使用しました。
Java コード:
@XmlRootElement(name = "rep")
public class Demo {
@XmlElement(name = "text")
private Text text;
@Override
public String toString() {
return text.toString();
}
}
@XmlRootElement(name = "text")
public class Text {
@XmlValue
private String text;
@Override
public String toString() {
return "[text=" + text + "]";
}
}
出力:
[text= thank you]]]
しかし、次のような結果が必要です。
[!CDATA[Demo, <a href="http://www.google.com" target="_blank">Search</a> thank you]]
また
Demo, <a href="http://www.google.com" target="_blank">Search</a> thank you