You can use your own .NET method to escape special characters in text. Of course, there are only 5 special characters, and 5 calls to Replace () will probably work, but I'm sure there must be something inline.
"&" "&"
, , SecurityElement. , - SecurityElement.Escape(string s) XML.
, , Infopath Text, , , "&" ,
XML
"<" to "<"
">" to ">"
"\"" to """
"'" to "'"
"&" to "&"
"System.Security". . Http://msdn2.microsoft.com/en-us/library/system.security.securityelement.escape(VS.80).aspx
-
public static string EscapeXml( this string s )
{
string toxml = s;
if ( !string.IsNullOrEmpty( toxml ) )
{
toxml = toxml.Replace( "&", "&" );
toxml = toxml.Replace( "'", "'" );
toxml = toxml.Replace( "\"", """ );
toxml = toxml.Replace( ">", ">" );
toxml = toxml.Replace( "<", "<" );
}
return toxml;
}
public static string UnescapeXml( this string s )
{
string unxml = s;
if ( !string.IsNullOrEmpty( unxml ) )
{
unxml = unxml.Replace( "'", "'" );
unxml = unxml.Replace( """, "\"" );
unxml = unxml.Replace( ">", ">" );
unxml = unxml.Replace( "<", "<" );
unxml = unxml.Replace( "&", "&" );
}
return unxml;
}