C# 使用xml属性名称反序列化->;财产
假设我有以下XMLC# 使用xml属性名称反序列化->;财产,c#,serialization,deserialization,C#,Serialization,Deserialization,假设我有以下XML <doc> <float name="score">7.8753223</float> <str name="author">asdadsad</str> <str name="body">...</str> <str name="category">haelth-safety</str> </doc> 如何告诉序列化程序使
<doc>
<float name="score">7.8753223</float>
<str name="author">asdadsad</str>
<str name="body">...</str>
<str name="category">haelth-safety</str>
</doc>
如何告诉序列化程序使用xml属性名称将数据映射到c#属性?对于指定的xml格式,无法使用声明式(属性化)序列化。如果要使用声明式序列化,请将格式更改为以下格式:
<doc>
<score>7.8889798</score>
<author>agfdfg</author>
<body>...</body>
<category>haleth safet</category>
</doc>
7.8889798
agfdfg
...
海利斯·萨菲特
并使用XmlElementAttribute为序列化的属性指定相应的元素名称。XML来自Solr,因此我无法控制:/然后您必须自定义序列化。谷歌搜索
IXmlSerializable
。可能重复
<doc>
<score>7.8889798</score>
<author>agfdfg</author>
<body>...</body>
<category>haleth safet</category>
</doc>