JAXB Annotation When XML Root Node contains PCData -
i'm trying consume data 3rd party web service. unfortunately, web service returning data in i'd unusual xml format. here sample of data receiving service:
<?xml version="1.0" encoding="utf-8"?> <string xmlns="http://mynamespace">(-76.4844131, 39.1031567, 0.0000000) (-76.4871168, 39.1031567, 0.0000000) (-76.4875889, 39.1042890, 0.0000000) (-76.4905500, 39.1052881, 0.0000000) </string>
instead of having root node contains list of waypoint elements (lat, lon, elevation), root node's content large string value. while parse string, hoping use jaxb (since i'm using jersey service calls) convert returned xml java poco.
ideally, nice convert large string body of root node poco class list of waypoints, imagine require custom xml deserialization outside of jaxb.
but i'd happy if use jaxb:
@xmlrootelement(name="string", namespace="http://mynamespace") public class route { private string _waypoints; @ ???? public string getwaypoints() { returns _waypoints; } public void setwaypoints(string waypoints) { _waypoints = waypoints; } }
unfortunately, haven't seen way in jaxb tell marshaller 1 of properties should content of either root element or other element.
ideally nice if annotate property like:
@xmlelementcontent(elementname="string")
and marshal/unmarshal content of waypoint property content (or innertext) of root element.
has had similar issue? there way jaxb? or should consider parsing string and/or writing custom xml deserializer.
thanks!
you can use @xmlvalue
@xmlvalue public string getwaypoints() { returns _waypoints; }
Comments
Post a Comment