phannhatnghi
New Member
here's an extract from an XML I'd like to parse :\[code\]<node version="1.0.7" errorCode="0" message="">\[/code\]errorCode is actually a fixed set of constants so I thought it would be a good idea to represent it as an enum :\[code\]public enum ErrorCode { OK (0,"ok"), ERR (1,"Error"), BIGERR (2,"Big Error"); private int code; private String name; ErrorCode(int code, String name) {...}}\[/code\]I don't know how to map the "0" from the xml file with the various constants defined in my enum...I keep on getting a conversion exception with no enum constant :\[code\]com.thoughtworks.xstream.converters.ConversionException: No enum constant my.package.ErrorCode.0\[/code\]I don't know how I could specify an alias for the values...(or if i have to implement my own converter.).Thanks..