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.
In XML and XHTML, a self-closing tag is a shorthand notation for an opening and closing tag in one. It's used to communicate lack of content in between the opening and closing tags. So, rather than typing <p></p> (with no space at all in between), you'd be able write <p/> .
XML serialization does not convert methods, indexers, private fields, or read-only properties (except read-only collections). To serialize all an object's fields and properties, both public and private, use the DataContractSerializer instead of XML serialization.
The end tag functions exactly like a right parenthesis or a closing quotation mark or a right curly brace. It contains no data of its own; it simply ends the most recent (innermost) tag with the same name.
Xml. Serialization namespace) class is used to serialize and deserialize. The class method Serialize is called. Since we have to serialize in a file, we create a " TextWriter ".
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With