当我从提要中获取数据并通过正则表达式提取内容时,我仍然拥有(&o#8230;、&o#8211;、&o#8220 等...[我在前 2 个中添加了 o,以便他们重新格式化] ) 在我的内容文本中。可悲的是,这些也在提要内容的来源中。我自己尝试了一些正则表达式但没有成功:&#[0-9]{4};
我的代码:
protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
{
try
{
SyndicationItem sItem = IsolatedStorageSettings.ApplicationSettings["postovi"] as SyndicationItem; //stores the user chosed item to be displayed
List <string> CC_List = IsolatedStorageSettings.ApplicationSettings["ContentList"] as List<string>; //title and content are pulled from feed and put in list
PageTitle.Text = sItem.Title.Text;
PageTitle.FontSize = 40;
foreach (var item in CC_List)
{
int i;
if (item == PageTitle.Text)
{
i = CC_List.IndexOf(item, 0); //index naslova u listi
String content = CC_List[i + 1];
content = Regex.Replace(content, @"(?<startTag><\s*script[^>]*>)(?<content>[\s\S]*?)(?<endTag><\s*/script[^>]*>)", string.Empty);
Match link = Regex.Match(content, @"(?<=<img\s+[^>]*?src=(?<q>['""]))(?<url>.+?)(?=\k<q>)", RegexOptions.Singleline);
content = Regex.Replace(content, @"(?></?\w+)(?>(?:[^>'""]+|'[^']*'|""[^""]*"")*)>", string.Empty);
content = Regex.Replace(content, " ", string.Empty);
Uri uri = new Uri(link.Value);
slika_clanak.Source = ImageFromUri(link.Value); // gets image
content = Regex.Replace(content, @"<p>.*</p>", string.Empty);
clanak_textblock.Text = content.Trim(); // reads article text and puts it on screen
}
}