Hinweis
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, sich anzumelden oder das Verzeichnis zu wechseln.
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, das Verzeichnis zu wechseln.
The Toolkit RssParser has been removed. Code should be migrated to use the System.ServiceModel.Syndication API instead.
This document will show you how to migrate over to the .NET Standard library API.
Migration Steps
- Remove the
Microsoft.Toolkit.Parserspackage. - Add the
System.ServiceModel.Syndicationpackage. - Replace
HttpClient+GetStringAsyncwithXmlReader.Create. - Replace
RssParser+ParsewithSyndicationFeed.Load. - Append
.Textto any element properties retrieved.
Warning
If updating a UWP based project, Visual Studio will recommend the Windows.Web.Syndication namespace by default. Be sure to ignore this suggestion and instead include the System.ServiceModel.Syndication NuGet package and namespace.
Toolkit Example
public async void ParseRSS()
{
string feed = null;
using (var client = new HttpClient())
{
try
{
feed = await client.GetStringAsync("https://visualstudiomagazine.com/rss-feeds/news.aspx");
}
catch { } // TODO: Deal with unavailable resource.
}
if (feed != null)
{
var parser = new RssParser();
var rss = parser.Parse(feed);
foreach (var element in rss)
{
Console.WriteLine($"Title: {element.Title}");
Console.WriteLine($"Summary: {element.Summary}");
}
}
}
Public Async Sub ParseRSS()
Dim feed As String = Nothing
Using client = New HttpClient()
Try
feed = Await client.GetStringAsync("https://visualstudiomagazine.com/rss-feeds/news.aspx")
Catch
End Try
End Using
If feed IsNot Nothing Then
Dim parser = New RssParser()
Dim rss = parser.Parse(feed)
For Each element In rss
Console.WriteLine($"Title: {element.Title}")
Console.WriteLine($"Summary: {element.Summary}")
Next
End If
End Sub
.NET Example
public void ParseRSSdotnet()
{
SyndicationFeed feed = null;
try
{
using (var reader = XmlReader.Create("https://visualstudiomagazine.com/rss-feeds/news.aspx"))
{
feed = SyndicationFeed.Load(reader);
}
}
catch { } // TODO: Deal with unavailable resource.
if (feed != null)
{
foreach (var element in feed.Items)
{
Console.WriteLine($"Title: {element.Title.Text}");
Console.WriteLine($"Summary: {element.Summary.Text}");
}
}
}
Public Sub ParseRSSdotnet()
Dim feed As SyndicationFeed = Nothing
Try
Using reader = XmlReader.Create("https://visualstudiomagazine.com/rss-feeds/news.aspx")
feed = SyndicationFeed.Load(reader)
End Using
Catch
End Try
If feed IsNot Nothing Then
For Each element In feed.Items
Console.WriteLine($"Title: {element.Title.Text}")
Console.WriteLine($"Summary: {element.Summary.Text}")
Next
End If
End Sub