XStream and underscores
This worked for me:
XStream xs = new XStream(new DomDriver("UTF-8", new XmlFriendlyNameCoder("_-", "_")));
XStream uses the underscore to escape characters in identifiers that are valid in Java but invalid in XML (see here). So the underscore itself has to be escaped. You can use a custom NameCoder
as described in the FAQ.
That said I normally can get along with the NoNameCoder
. But: Don't use underscores in Java property identifiers, if possible; it is untypical for Java and against the Java Naming Conventions.