3

I working on JAXB to using java object I am creating xml.But im using javaclass fields Like

qpack_id as attrubute it creating in xml file like qpackId

so how can i use _(underscore) in jaxB please guide me.

xml file should create bellow attibute

<qpack " qpack_id="MB0046_SET4" qpack_name="MB0046">
</qpack>
Ian Roberts
  • 120,891
  • 16
  • 170
  • 183
user1906191
  • 51
  • 2
  • 7

1 Answers1

3

Starting from Java Classes

You can use the XmlAttribute annotation to specify a name.

@XmlAttribute(name="qpack_name")
public String getQPackName() {
    return qPackName;
}

Starting from XML Schema

If you are talking about generating Java classes from an XML schema and preserving the _ character in the Java properties names see the answer below for a complete example:

Community
  • 1
  • 1
bdoughan
  • 147,609
  • 23
  • 300
  • 400