XML cannot be parsed if it contains special characters, so it must be escaped.
Five characters to be escaped in XML:
& Symbol
<Yu no.
> Yu ID
'Single quotes
"Double quotation marks
It is tested that single quotes and double quotes are correct even if they are not converted.
In addition, it should be noted that, if it is a full-width, not a half-width, XML parsing is no problem.
Specialcharmap = new hashmap <string, string> ();
Specialcharmap. Put ("&", "& amp ;");
Specialcharmap. Put (">", "& gt ;");
Specialcharmap. Put ("<", "& lt ;");
Specialcharmap. Put ("'", "& apos ;");
Specialcharmap. Put ("\" "," & quot ;");
Public static string formatstringinxml (string value) {If (value! = NULL &&! "". Equals (value) {If (specialcharmap! = NULL & specialcharmap. size ()> 0) {for (Entry <string, string> entry: specialcharmap. entryset () {value = value. replaceall (entry. getkey (), entry. getvalue () ;}} return value ;}