gpt4 book ai didi

c# - 是否可以在 XSL 中展平 XML 层次结构?

转载 作者:数据小太阳 更新时间:2023-10-29 02:27:50 26 4
gpt4 key购买 nike

我对 XML 文件有以下结构:

<INSTANCE>
<Sections>
<Section>
<Forms>
<Form>
<Control id="GroupHeading1">
<Property/>
<Property/>
</Control>
<Control id="GroupHeading2">
<Property/>
<Control id="TextBox">
<Property/>
<Property/>
</Control>
</Control>
</Form>
</Forms>
</Section>
</Sections>
</INSTANCE>

我正在尝试将其反序列化为 C# 对象,但我不需要保留层次结构(这让我很难反序列化)。

是否有 XSL 可以将其转换为取消嵌套控件,并在可能的情况下向任何具有 ParentId=""的子控件添加属性?

感谢您的指导!

最佳答案

给定 XML,XmlSerializer 可以生成包含相同实例数据的对象图。
这称为 XML 反序列化

你需要看这里:

关于c# - 是否可以在 XSL 中展平 XML 层次结构?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5444342/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com