using System; using System.Collections.Generic; using System.Text.RegularExpressions; using System.Xml; using System.Windows.Data; namespace RssReader { /// /// removeHTMLTags provides a one-way conversion from HTML to a string that doesn't contain HTML-Tag. /// public class removeHTMLTags : IValueConverter { public object Convert ( object value, Type targetType, object parameter, System.Globalization.CultureInfo culture ) { String _str = ""; if ( value != null ) { XmlElement xml = ( XmlElement )value; XmlNode node = xml.FirstChild; _str = node.Value; // JavaScript Regex re1 = new Regex ( "<(no)?script.*?script>", RegexOptions.IgnoreCase | RegexOptions.Singleline ); // HTML Tags Regex re2 = new Regex ( "<.*?>", RegexOptions.Singleline ); // code Regex re3 = new Regex ( "\n+", RegexOptions.Singleline ); // Replace _str = re1.Replace ( _str, "" ); _str = re2.Replace ( _str, "" ); _str = re3.Replace ( _str, "\n" ); } return _str; } public object ConvertBack ( object value, Type targetType, object parameter, System.Globalization.CultureInfo culture ) { return null; } } }