【发布时间】:2015-03-11 02:55:56
【问题描述】:
我有如下的 XML:
<CallStep>
<StepXaml>
<StackPanel xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:uc="clr-namespace:CallTracker.Library.UserControls.BaseUserControls;assembly=CallTracker.Library">
<uc:LabelValueControl Label="TestLabel" Value="356733" />
</StackPanel>
</StepXaml>
</CallStep>
然后我想存储在一个属性中
[XmlElement("StepXaml")]
public object StepXaml { get; set; }
我正在使用 XmlSerializer 将 XML 反序列化为包含 StepXaml 属性的类。目前,当我反序列化 XML 时,<StackPanel> 正在反序列化到它自己的节点中。
有没有办法防止反序列化器尝试深入了解<StackPanel>,而是将<StepXaml> 和</StepXaml> 之间的所有内容作为一个对象返回?
【问题讨论】:
标签: c# xml xml-deserialization