简体   繁体   中英

How can I avoid unwanted XML Tags with JAXB. Too much binding?

The Code Below allows me to write an Object into an XML file.

public class BathGuest{

private String name = "";
private DateMinutesHours wakeUpTime;
private int duration = 0;
private DateMinutesHours _plannedTime;

@XmlElement(name ="plannedTime")
public DateMinutesHours get_plannedTime() {
    return _plannedTime;
}

@XmlElement(name = "ID")
public String getName() {
    return _name;
}

...

}

The problem I have is, that birthday is an other Class to handle my timeoperations. So the result of my XML File, is not really what i expected.

What I get is:

<bathroomEntity>
    <duration>3</duration>
    <ID>Walter</ID>
    <startTime>
        <totalMinutes>481</totalMinutes>
    </startTime>
    <plannedTime>
        <totalMinutes>485</totalMinutes>
    </plannedTime>
</bathroomEntity>

And what I want is:

<bathroomEntity>
    <duration>3</duration>
    <ID>Walter</ID>
    <startTime>08:10</startTime>
    <plannedTime>08:50</plannedTime>
</bathroomEntity>

How can I reach the Second XMl-File?

如果您注释totalMinutes对房地产DateMinutesHours带班@XmlValue那么你会得到你所lookiing的行为。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM