0

I have a little issue, i'm trying to get the coordinates in XML(Atom-feed) response with Jaxb but i can't. The customs namespaces as < str name="footprint"> are the problem.

Indeed, i already tried with a standard namespace like < summary > and it's working.

It's the first time that i play with xml stuff, so i dont know how to access to those namespaces.

Here's the code:


@XmlRootElement(name = "entry")
@XmlAccessorType(XmlAccessType.FIELD)
public class Entry {
    //@XmlElement(name = "footprint")//<str name="footprint"> dont work.
    //@XmlAttribute(name="footprint")//dont work
    @XmlValue//dont work
    private String footprint;

    @XmlElement(name = "uuid")
    private String id;

    @XmlElement(name = "size")
    private String size;

    public Entry() {}

    public String getCoordinates() {
        return footprint;
    }

    public String getId() {
        return id;
    }

    public String getSize() {
        return size;
    }

    public void setCoordinates(String footprint) {
        this.footprint=footprint;
    }
    public void setSize(String size) {
        this.size=size;
    }
    public void setId(String id) {
        this.id=id;
    }

}

And what i want to get :

XML

Thank you.

EDIT :

Solution => I can't access to the namespace <str name="footprint'> with Jaxb

Girbouillle
  • 73
  • 1
  • 13
  • Tried mapping name to an `@XmlAttribute` and coordinates as the `@XmlValue` of the `str` type? – areus Apr 02 '20 at 16:12
  • Not yet, I will try this tomorow. Thanks! – Girbouillle Apr 03 '20 at 00:17
  • @areus i tried but it doesn't work. The XmlAttribute gave me the same result => null. And XmlValue doesn't like the XmlElement property. I have this XmlRootElement(name = "entry"). (i update the post with the complete class) – Girbouillle Apr 03 '20 at 11:14
  • Yóu could generate the classes from the xsd. Have a look at https://stackoverflow.com/questions/11463231/how-to-generate-jaxb-classes-from-xsd – areus Apr 03 '20 at 13:30
  • Does this answer your question? [JAXB: How to bind element with namespace](https://stackoverflow.com/questions/8038821/jaxb-how-to-bind-element-with-namespace) – Joe Apr 19 '20 at 12:09
  • This post answer my question : https://stackoverflow.com/questions/61012517/i-cant-access-to-the-namespace-str-name-footprint-with-jaxb – Girbouillle Apr 22 '20 at 12:26

0 Answers0