【发布时间】:2016-12-18 19:58:02
【问题描述】:
我正在反序列化大型 xml 文档。在大多数情况下,这很好。我不关心树下的一些子节点,但它们确实包含我想捕获以供以后可能使用的数据,但是我不想完全反序列化这些。我宁愿获取整个节点并将其存储为一个字符串,以便稍后返回。
例如,给出下面的 xml 文档:
<item>
<name>item name</name>
<description>some text</description>
<categories>
<category>cat 1</category>
<category<cat 2</category>
</categories>
<children>
<child>
<description>child description</description>
<origin>place of origin</origin>
<other>
<stuff>some stuff to know</stuff>
<things>I like things</things>
</other>
</child>
</children>
</item>
我想在 other 节点中读取,并将内部 xml 存储为字符串(即“
在我的item 课程中,我尝试了其他属性上的各种System.Xml.Serialization 属性,但没有成功,例如XmlText、XmlElement 等。
我该如何做到这一点?这似乎是一项相当普遍的任务。
【问题讨论】:
标签: c# xml serialization deserialization