There is no such thing as a "html tag". There are namespaces and
element names, and if you define your annotated classes accordingly,
you can expect to unmashal an <ab> element into an object with a field
P of type String.
-W
On 16 February 2011 19:07, <alessandro.falasca_at_gmail.com> wrote:
> Hi All,
> I'm using JAXB for Marshalling/Unmarshalling an xml, in the following
> example I have some html tags inside the text and it doesn't work as I
> respected.
>
> For example:
>
> package test;
> import javax.xml.bind.annotation.XmlElement;
> import javax.xml.bind.annotation.XmlType;
>
>
> @XmlType(name="record")
> public class MyRecord {
>
>
> private String abstractText;
>
> private String authorAffiliation;
>
>
> @XmlElement(name = "ab")
> public String getAbstractText() {
> return abstractText;
> }
>
> public void setAbstractText(String abstractText) {
> this.abstractText = abstractText;
> }
>
>
> @XmlElement(name = "aa")
> public String getAuthorAffiliation() {
> return authorAffiliation;
> }
>
> public void setAuthorAffiliation(String authorAffiliation) {
> this.authorAffiliation = authorAffiliation;
> }
>
> }
>
> -----------------------------------------------------------------------
> -------------------
>
> @XmlRootElement(name="records")
> public class MyRecords {
>
> @XmlElement(name="record")
> /*
> public MyRecord getMyRecords() {
> return myRecords;
> }
>
> public void setMyRecords(MyRecord myRecords) {
> this.myRecords = myRecords;
> }
> private MyRecord myRecords;
> */
>
>
> public List<MyRecord> getMyRecords() {
> return myRecords;
> }
>
> public void setMyRecords(List<MyRecord> myRecords) {
> this.myRecords = myRecords;
> }
>
> private List<MyRecord> myRecords;
> }
> -----------------------------------------------------------------------
> -------------------
>
> With this one work properly
>
> <?xml version="1.0" encoding="ISO-8859-1"?>
>
> <!DOCTYPE records SYSTEM "RecordsHTML.DTD">
>
>
> <records>
> <record>
>
> <ab>abstract content</ab>
>
> <aa>National</aa>
>
> <no>4</no>
>
> <cp>Japan</cp>
>
> </record>
> </records>
>
> this one not
> <?xml version="1.0" encoding="ISO-8859-1"?>
> <!DOCTYPE records SYSTEM "RecordsHTML.DTD">
> <records>
> <record>
> <ab><p>abstract content</p></ab>
> <aa>National</aa>
> <no>4</no>
> <cp>Japan</cp>
> </record>
> </records>
>
> because the abstractText property is empty.
>
> Is it possible to get the full content of the tag "ab" in the
> abstractText field, including the html tags?
>
> Kind Regards
> Alessandro
>