I am new in Jaxb i have one xml file which contain many attribute so i want the attribute with value
My XMl
<message_mapping>
<message Rtype="DIAGNOSTIC" direction="2" name="Diagnostic" mode="">
<field tag="USERNAME" source="I" tranData="username" required="false" dataType="string" defaultValue="" />
<field tag="PASSWORD" source="I" tranData="password" required="true" dataType="string" defaultValue="" />
<field tag="LOCALDATETIME" source="E" tranData="trxDateTime" required="true" dataType="string" defaultValue=""/>
</message>
</message_mapping>
Best How To :
I suppose you have your class MessageMapping.java which has in turn a list (or one? dunno) of message of type Message.java. Message.java in turn will be structured with a list of Field of type Field.java. The classes will be as follow:
@XmlAccessorType(XmlAccessType.FIELD)
public class Field {
@XmlAttribute
private String tag;
@XmlAtrribute
private String source;
@XmlAtrribute
private String tranData;
@XmlAtrribute
private String dataType;
@XmlAtrribute
private String defaultValue;
/*
GETTER AND SETTER HERE
*/
}
And Message.java like this:
@XmlAccessorType(XmlAccessType.FIELD)
public class Message {
private List<Field> fields;
private String Rtype;
private String direction;
private String name;
private String mode;
/*
GETTER AND SETTER HERE
*/
}
And ultimately message_mapping class will need to be built as you see fit to accomodate a list of message or a single one, dunno what are your specification. Hope it helps.