write a convertor, it should be something similar to the code snippet
class FieldDtoConvertor implements Converter {
@SuppressWarnings("unchecked")
public boolean canConvert(final Class clazz) {
return clazz.equals(FieldDto.class);
}
public void marshal(final Object value,
final HierarchicalStreamWriter writer,
final MarshallingContext context) {
final FieldDto fieldDto = (FieldDto) value;
writer.addAttribute(fieldDto.getAttributeName(), fieldDto.getAttributeValue());
}
}
And while using XStream,register the convertor
final XStream stream = new XStream(new DomDriver());
stream.registerConverter(new FieldDtoConvertor());