【发布时间】:2025-12-05 15:40:01
【问题描述】:
我想创建以下 XML。
一个父节点中有多个子节点,父节点包含与子节点相关的节点(作为子节点的默认节点),如果子节点缺少节点,父节点将作为故障转移并为 kis 提供默认节点。
<parents>
<parent>
<!--all parent related nodes will be here-->
<kid-prop>default kid prop</kid-prop><!--this is the default for all kids-->
<kids>
<kid>
<kid-prop>some data</kid-prop>
</kid>
<kid></kid><!--since this kid does not have have <kid-prop>, it will be taken from the parent-->
<kids>
<parent>
<parents>
如何以编程方式做到这一点很容易,问题是,是否有任何注释方式告诉 xmlreader 父母是孩子的故障转移,以防孩子遗漏一些东西
【问题讨论】:
标签: c# xml hierarchy xmlreader failover