如何在xml中正确添加结束标签

问题描述 投票:0回答:1
<test>
  <tool attr = "" sav="" >
       <def sa="" tes=""/>
       <def sa="" tes=""/>
                                 Here the tool tag should be closed
    <tool attr = "" sav="" >
       <def sa="" tes=""/>
       <def sa="" tes=""/>
    </tool>
 </tool>                  -->                  But its closing here
</test>



var ns = new XmlSerializerNamespaces();
ns.Add("", "");
var oSerialiser = new XmlSerializer(typeof(T));
var oStream = new FileStream(_filename, FileMode.Create);
oSerialiser.Serialize(oStream, this, ns);
oStream.Close();

如何使用c#代码在元素之后立即关闭结束标记而不使用xelement而是使用序列化器。

c# .net xml serialization xml-serialization
1个回答
0
投票
 class tool
 {
     [XmlAttribute]
     string attr;
     [XmlAttribute]
     string sav;
     [XmlElement]
     IList<string> def;   
 }
© www.soinside.com 2019 - 2024. All rights reserved.