我想序列化这样的东西,其中有一个标题和一个正文.
第一部分"galleryData"是标题第二部分是"imageData" - 为图库中的每个图像重复
<galleryData>
<title>some title</title>
<uuid>32432322</uuid>
<imagepath>some path</imagepath>
</galleryData>
<imageData>
<title>title one</title>
<category>nature</category>
<description>blah blah</description>
</imageData>
<imageData>
<title>title two</title>
<category>nature</category>
<description>blah blah</description>
</imageData>
<imageData>
<title>title three</title>
<category>nature</category>
<description>blah blah</description>
</imageData>
Run Code Online (Sandbox Code Playgroud)
如果我不需要标题区域,我会看到如何做到这一点.我目前只是使用xmlwriter来创建它,但我想将对象序列化为xml.