在我的 WPF 应用程序中,我想编写代码来读取 Atom xaml Feed。Web links
就像我www.myweblink/NewXaml.xaml
希望我的代码使用此链接并从此链接中定义的此 xaml 文件中获取标题和描述。
ATOM XAML.文件
<?xml version='1.0' encoding='UTF-8' ?>
<rss version='2.0' xmlns:atom='http://www.w7.org7/Atom'>
<channelWay>
<title>Text1 - Network</title>
<atom:link href='http://link1/myxaml.xml' rel='self' type='typeOne/rss+xml' />
<link>http://website.com</link>
<description> This is New Description </description>
<lastBuildDate>Fri, 2 Oct 2011 00:00:00 +0500</lastBuildDate>
<language>en-us</language>
<item>
<title>
My First Title
</title>
<link>http://website.com/PageOne.aspx?ID=123790</link>
<guid>http://website.com/PageTwo.aspx?ID=123790</guid>
<description>
My First Description
</description>
<pubDate>Fri, 2 Oct 2011 13:10:00 +0500</pubDate>
</item>
<item>
<title>
My Second Title
</title>
<link>
<link>http://website.com/PageOne1.aspx?ID=123790</link>
<guid>http://website.com/PageTwo1.aspx?ID=123790</guid>
<description>
My Second Description
</description>
<pubDate>Fri, 2 Oct 2011 13:10:00 +0500</pubDate>
</item> . . . . . .
读取 Xaml 文件的代码:
public Window1()
{
InitializeComponent();
FlowDocument content = null;
OpenFileDialog openFile = new OpenFileDialog();
openFile.Filter = "FlowDocument Files (*.xaml)|*.xaml|All Files (*.*)|*.*";
if (openFile.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
FileStream xamlFile = openFile.OpenFile() as FileStream;
if (xamlFile == null) return;
else
{
try
{
content = XamlReader.Load(xamlFile) as FlowDocument;
if (content == null)
throw(new XamlParseException("The specified file could not be loaded as a FlowDocument."));
}
catch (XamlParseException e)
{
String error = "There was a problem parsing the specified file:\n\n";
error += openFile.FileName;
error += "\n\nException details:\n\n";
error += e.Message;
System.Windows.MessageBox.Show(error);
return;
}
catch (Exception e)
{
String error = "There was a problem loading the specified file:\n\n";
error += openFile.FileName;
error += "\n\nException details:\n\n";
error += e.Message;
System.Windows.MessageBox.Show(error);
return;
}
FlowDocRdr.Document = content;
}
}
错误:它生成错误,rss
在 Xaml 文件中无效。
Q1:如何从这个 xaml 文件中获取标题和描述?
Q2:我希望我的程序自动转到此链接,而不是我必须将此文件保存在我的 PC 上并提供此代码的路径以使其硬编码。
谁能帮帮我吗。