Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/arrays/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Xml 在C#Net中反序列化RSS源_Xml_Arrays_C# 4.0_Deserialization - Fatal编程技术网

Xml 在C#Net中反序列化RSS源

Xml 在C#Net中反序列化RSS源,xml,arrays,c#-4.0,deserialization,Xml,Arrays,C# 4.0,Deserialization,我对反序列化非常陌生,但我被赋予了反序列化多个提要并提取数据进行操作的任务 我有一个RSS提要,它的结构如下: <channel> <title></title> <link></link> <description></description> <ttl></ttl> <item>

我对反序列化非常陌生,但我被赋予了反序列化多个提要并提取数据进行操作的任务

我有一个RSS提要,它的结构如下:

    <channel>
        <title></title>
        <link></link>
        <description></description>
        <ttl></ttl>
        <item>
            <title></title>
            <link></link>
            <description></description>
            <pubDate></pubDate>
            <guid></guid>
        </item>
        <item>
显然,我使用的是system.xml.serialization类

我担心的是,项数组中的元素不会得到它们应该得到的值,因为它们与数组外的元素共享名称。我是否正确创建了数组

我一直在使用这个结构来反序列化JSON提要,它在那里工作,但我不确定我是否正确地翻译了它

反序列化XML的实际方法是什么?我知道MSDN说我可以做什么(),但我只想确认一下。
干杯。

公开项目集类。
另外,看看这个项目:-也许您不需要实现相同的功能。

您可以使用XSD从XML模式生成类


谢谢,我错过了公开上课。我被明确告知不要为这个项目下载任何第三方插件或类,因为最终版本将在云上结束。一切都需要用VisualStudio2010中可用的工具来完成。Cheers,花了一些时间来研究它是如何工作的,但我想我已经做到了。能够看到自动生成的类是如何构造的,这使我更容易看到我应该如何做。
[XmlRoot("channel")]
public class RahChannel
{
    [XmlElement("title")]
    public string title { get; set; }

    [XmlElement("link")]
    public string link { get; set; }

    [XmlElement("description")]
    public string description { get; set; }

    [XmlElement("ttl")]
    public int ttl { get; set; }

    [XmlElement("item")]
    public ItemSet[] ItemArray { get; set; }
 }

[XmlArray]
class ItemSet
{
    [XmlElement("title")]
    public string itemtitle { get; set; }

    [XmlElement("link")]
    public string itemLink { get; set; }

    [XmlElement("description")]
    public string itemDescription { get; set; }

    [XmlElement("pubDate")]
    public string pubDate { get; set; }

    [XmlElement("guid")]
    public string guid { get; set; }
}