Basically, I want to do the reverse of this question.
I'm getting XML from Microsoft's Bing batch Geocode service, and some of the elements look like this (poached from here):
<DataflowJob>
<Id>5bf10c37df944083b1879fbb0556e67e</Id>
<Link role="self">https://spatial.virtualearth.net /REST/v1/dataflows/Geocode/5bf10c37df944083b1879fbb0556e67e</Link>
<Link role="output" name="succeeded">https://spatial.virtualearth.net/REST/v1/dataflows/Geocode/5bf10c37df944083b1879fbb0556e67e/output/succeeded</Link>
<Link role="output" name="failed">https://spatial.virtualearth.net/REST/v1/dataflows/Geocode/5bf10c37df944083b1879fbb0556e67e/output/failed</Link>
<Description>Xml</Description>
<Status>Completed</Status>
...
</DataflowJob>
Notice that the <Link>
elements have attributes as well as text content. Here are the relevant POJO classes I'm trying to deserialize to:
class DataflowJob
{
String Id;
@XStreamImplicit
List<Link> Links;
String Description;
Status Status;
...
}
class Link
{
@XStreamAsAttribute
Role role;
@XStreamAsAttribute
Name name;
String url;
}
With my current configuration (classes are aliased, attributes auto-detected, and all that jazz), XStream properly deserializes the Name
and Role
attributes on the <Link>
elements, but not the actual link text itself.
How do I get XStream to deserialize that text into a String
field in a Link
object?
I don't want to have to manually insert new elements around the link text* just for this.
*e.g., replace
<Link role="self">
https://long/url/here
</Link>
with
<Link role="self">
<url>https://long/url/here</url>
</Link>