First of all I am new to Jaxb and most defiantly have not wrapped my head completely around it.
I would like to use annotation to pares Xml but instead of generating binding classes I would just like to extract a portion of the xml and return it as a Java.lang.String. No marshalling or unmarshalling need. Just want to extract from xml.
Let's say my XML is structured as followed
<root>
<topMovies>
<string>The Godfather (1972)</string>
<string>The Shawshank Redemption (1994)</string>
<string>The Godfather: Part II (1974)</string>
<string>The Lord of the Rings: The Return of the King (2003)</string>
<topMovies>
<root>
And I would like to extract the above XML snippet (topMovies).
This won't work of course but might give an idea of what I am trying to say.
@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement(name = "root")
public class GetTopMovies {
@XmlElement(name = "topMovies")
protected java.lang.String getTopMovies;
}
In the end I want a java String with the extracted xml (not taking escaping into account).
String topMovies =
"<topMovies>
<string>The Godfather (1972)</string>
<string>The Shawshank Redemption (1994)</string>
<string>The Godfather: Part II (1974)</string>
<string>The Lord of the Rings: The Return of the King (2003)</string>
<topMovies>
";
Can this be done with JAXBElement or and XmlAdapter or creating a special Object Factory?