net xmlserializer:保持属性顺序 [英] net xmlserializer : keeping attributes order
问题描述
我可以成功地在 xml 文件中编写我的类项.但是属性的顺序改变了...
I can sucessfully able to write my class Item in a xml file. But the orders of atttributes change...
假设我有 Item 类
Suppose I have Item class
class Item
{
Name
Price
Id
}
当我使用 .net xmlserializer 将它写入 xml 文件时,我从我的类声明中得到不同的顺序,例如
when I write it to xml file using .net xmlserializer I get different order from my class decleration such as
<Item Price="y" Name="x" Id="z" />
但我想要这样[保持decleration order]
But I want it like this [ keep decleration order]
<Item Name="x" Price="y" Id="z" />
我如何在 NET 中做到这一点?
How can İ do it in NET?
推荐答案
您不应该关心订单.如果是,则说明您没有正确处理 xml
You shouldn't be concerend with the order. If you are, then you are not processing your xml properly
第 3.1 节注意属性规范在一个开始标签或空元素标签不重要."
section 3.1 "Note that the order of attribute specifications in a start-tag or empty-element tag is not significant."
这篇关于net xmlserializer:保持属性顺序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!