public final class XMLUtils extends Object
| Modifier and Type | Method and Description |
|---|---|
static String |
escape(String s)
Replaces characters which are invalid in element values, by the corresponding entity
in a given
String. |
static String |
escapeAttr(String s)
Replace characters which are invalid in attribute values,
by the corresponding entity in a given
String. |
static String |
toElementName(String name)
Return a valid element name from the given string.
|
public static String escape(String s)
String.
these characters are:
Empty strings or null return respectively "" and null.
Note: this function assumes that there are no entities in the given String. If there are existing entities, then the ampersand character will be escaped by the ampersand entity.
This method does not replaces " (by ") which is an invalid character in attribute values.
s - The String to be parsednull or empty.escapeAttr(java.lang.String)public static String escapeAttr(String s)
String.
these characters are:
Empty strings or null return respectively
"" and null.
Note: this function assumes that there are no entities in the given String. If there are existing entities, then the ampersand character will be escaped by the ampersand entity.
s - The String to be parsednull or empty.public static String toElementName(String name)
Letters are put to lower case and other characters are replaced by hyphens. If the first character is not a letter it is replaced by 'x'.
name - The candidate element nameCopyright © 2007-2022. All Rights Reserved.