Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

use & symbole in xml as a text using c#

public static string EscapeXml( this string s )
{
  string toxml = s;
  if ( !string.IsNullOrEmpty( toxml ) )
  {
    // replace literal values with entities
    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 ) )
  {
    // replace entities with literal values
    unxml = unxml.Replace( "'", "'" );
    unxml = unxml.Replace( """, """ );
    unxml = unxml.Replace( ">", ">" );
    unxml = unxml.Replace( "<", "<" );
    unxml = unxml.Replace( "&", "&" );
  }
  return unxml;
}
Comment

PREVIOUS NEXT
Code Example
Csharp :: how to center a window in monogame 
Csharp :: how to make dobuble jump unity 2d 
Csharp :: blender how to switch cameras 
Csharp :: tee into file 
Csharp :: c# switch two values 
Csharp :: C# Payroll 
Csharp :: how to make continuous progress bar 
Csharp :: ignore warning openxml 
Csharp :: how to display only date from datetime in mvc view 
Csharp :: compass direction mobile unity 
Csharp :: .net core best package for scheduler 
Csharp :: WPF raotate Icon 
Csharp :: leave two decimal in double c# 
Csharp :: c# condition and 
Csharp :: ilist validation wpf mvvm 
Csharp :: how to create advance search with parameter in asp.net mvc 
Csharp :: grass download for unityh 
Csharp :: null objects 
Csharp :: unity raycast hit child object 
Csharp :: appodeal unity integration 
Csharp :: linq pick random element 
Csharp :: eleventy set default layout 
Csharp :: c# string split by length 
Csharp :: dotnet core webapp 
Csharp :: c# winforms input 
Csharp :: leantween move ui 
Csharp :: get multi-selected rows gridcontrol devexpress 
Csharp :: how disable the back off a panel C# 
Csharp :: population of the world 
Html :: html disable editing textbox 
ADD CONTENT
Topic
Content
Source link
Name
1+3 =