users@jaxb.java.net

Re: get text using JAXB

From: Mirko Klemm <mirko_at_cm-klemm.de>
Date: Wed, 25 Feb 2015 11:48:05 +0100

Hi Alberto,
it seems what you are trying to do is process a so-called „mixed content“ element with JAXB.

JAXB handles this as a property of type „List<E>“, where „E“ can be of several types.

I suggest you refer to the documentation, like this one:

https://jaxb.java.net/tutorial/section_2_2_12_7-Mixed-Content.html

to get more info about this.
Regards,
Mirko

> Am 2015-02-25 um 11:40 schrieb alberto.cogolludo_at_celersol.com:
>
> Hi
>
> In my app, I'm reading a xml file (with JAXB) but there is times that I
> have empty segments.
>
> I put some examples
>
> <tuv>
> <seg>Unknown: the action taken should always be known</seg>
> </tuv>
> Here I read well the tag "seg", I can get all text "Unknown: the action
> taken should always be known" but if this text is like this:
>
> <tuv>
> <seg><bpt i="1" x-wb-tag="b1" />Unknown<ept i="1" x-wb-tag="/b1"
> />: the action taken should always be known</seg>
> </tuv>
> I don't get anything, my variable is empty and I want to get all text
> "<bpt i="1" x-wb-tag="b1" />Unknown<ept i="1" x-wb-tag="/b1" />: the
> action taken should always be known"
>
> Could I get this text "<bpt i="1" x-wb-tag="b1" />Unknown<ept i="1"
> x-wb-tag="/b1" />: the action taken should always be known" or only
> "Unknown: the action taken should always be known" (without tag "ept"
> and "bpt"? (I want this like a string)
>
> Note: my variable's value is a "string"
>
> Thanks!