问题
I am working with VB.NET and I am facing a problem with XML serialization. When empty values exists in the object I am serializing, the XML file contains the following tags:
<tagName/>
instead of:
<tagName></tagName>
I know that it's the same, but I want the start tag to close appropriately.
回答1:
They are the same and it makes no difference. Any parser or reader understands the meaning, so why is this so important to change?
I find the current behavior better as it will result in smaller files.
Regardless, there is no way to override this behavior.
来源:https://stackoverflow.com/questions/4932093/is-there-a-way-to-avoid-self-closing-tags-when-using-xml-serialization