Sunday, 15 April 2012

c# - Remove special characters from XmlCompiledTransform -


I am taking a DataSet , load it into XmlDocument I am trying to replace it with XSLT file and delete special characters from my output file.

Short code:

  DataSet ds = GetData (); // Question Database XmlDocument doc = New XmlDocument (); Doc.LoadXml (ds.GetXml ()); XslCompiledTransform trans = New XmlCompiledTransform (); Trans.Load ("myTemplate.xslt"); XmlTextWriter Author = New XmlTextWriter ("C: \ output.xml", encoding. GetEncoding ("ISO-885 901")); Trans.Transform (doctor, blank, author); Writer.Close ();   

XSLT header

  & lt ;? XML version = "1.0" encoding = "ISO-8859-1"? & Gt; & Lt; Xsl: stylesheet version = "1.0" xmlns: xsl = "http://www.w3.org/1999/XSL/transform" & gt;   

I thought it was to do with encoding only, this is the reason I got the encoding. Gate encoding ("ISO-885 9-1") was put there, although I may have to be wrong, in particular, I have to remove characters from the output like I®. If this is not an encoding, then is there any way that I can exclude these characters?

You can try using Regex to remove all special characters < Public static string RemoveSpecialCharacters (String Specialists) {Reggae Reggae = New Reggae ("(?: [^ A-z0-9] | (? & Lt; = ['\"]), "RegexOptions. IgnoreCase | RegexOptions.CultureInvariant | RegexOptions.Compiled); Return regex.Replace (Special Characters, String.Empty);}

Just adjust your code so that you keep some special characters Which you should

No comments:

Post a Comment