Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-mvc/17.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
C# 使用MvcContrib'时,xml元素名称中的小写字母;XmlResult_C#_Asp.net Mvc_Xml_Mvccontrib - Fatal编程技术网

C# 使用MvcContrib'时,xml元素名称中的小写字母;XmlResult

C# 使用MvcContrib'时,xml元素名称中的小写字母;XmlResult,c#,asp.net-mvc,xml,mvccontrib,C#,Asp.net Mvc,Xml,Mvccontrib,我上过这样的课 public class Reply { public string Result { get; set; } public int Code { get; set; } public string Description { get; set; } } 当我使用它作为XmlResult构造函数的参数时,我得到一个输出,其中xml元素名的首字母是大写的。但我需要它们是纯小写的。也许我错过了某种属性?不幸的是,我还没有找到任何关于XmlResult的文档。

我上过这样的课

public class Reply
{
    public string Result { get; set; }
    public int Code { get; set; }
    public string Description { get; set; }
}

当我使用它作为XmlResult构造函数的参数时,我得到一个输出,其中xml元素名的首字母是大写的。但我需要它们是纯小写的。也许我错过了某种属性?不幸的是,我还没有找到任何关于XmlResult的文档。

对于序列化,您可以添加:

[XmlElement("loweredname")] 

分别用于XML元素和属性。希望这能满足你的需要

更新:您的类应该是:

[XmlRoot("reply")]
public class Reply
{
    [XmlElement("result")]
    public string Result { get; set; }
    [XmlElement("code")]
    public int Code { get; set; }
    [XmlElement("description")]
    public string Description { get; set; }
}

您总是可以直接转到MVCContrib源代码:XMLElement属性有一个ElementName参数,您可能想试试。是的,这正是我所认为的。但是,我仍然无法将XmlElement应用于整个类,因此我得到而不是。我是否需要创建一些将Reply作为其属性的包装器,并在其中设置XmlElement?使用[XmlRoot(“loweredname”)]作为class@HiveHicks或者
XmlType(“loweredname”)
如果它实际上不是根
[XmlRoot("reply")]
public class Reply
{
    [XmlElement("result")]
    public string Result { get; set; }
    [XmlElement("code")]
    public int Code { get; set; }
    [XmlElement("description")]
    public string Description { get; set; }
}