我的当前XML结构如下:
<Parent>
<Child>
<Line id="1">Something</Line>
<Line id="2">Something</Line>
</Child>
<Child>
<Line id="1">Something else</Line>
<Line id="2">Something else</Line>
</Child>
</Parent>
父类代码包含属性:
[XmlElement("Child")]
public List<Child> Childrens { get; set; }
现在我想要将其更改为:
<Parent>
<Child>
<Line id="1">Something</Line>
<Line id="2">Something</Line>
</Child>
<SpecialChild>
<Line id="1">Some other text</Line>
<Line id="2">Some other text</Line>
</SpecialChild>
</Parent>
比如说,当 Child 设置了一些特殊的标志时,它的名称应该更改,并打印一些其他文本。根据标志,Child已经知道要打印哪个文本。
但现在最好的选项是改变元素名称吗?