tags:

views:

84

answers:

1

The rules for defining a properly constructed XML name are defined here.

C# has a utility method to convert strings into a valid XML name: XmlConvert.EncodeName.

What is the Java equivalent of this utility method?

Note: XML names must begin with a letter, _, or : character. After the first character, be composed only of letters, digits, ., -, _, and : characters.

A: 

I am not entirely sure what you are looking for but how about QName (http://java.sun.com/javase/6/docs/api/javax/xml/namespace/QName.html), there is a valueOf() method that might be what you are looking for.

Hope this helps.

cjstehno
Not what I am looking for. QName.valueOf("foo+").toString(); yields "foo+". Note that the "+" was not converted.
Julien Chastang