简体   繁体   中英

XML serialization namespace and XSD Generation

Is there a way to control the order that XmlSerializer generates the namespace and XSD when serializing an object, or at least have some control over what it generates in the header.

The code I've got generates the following xml and on another pc the order of the namespace and XSD is switched around, normally I doubt this would be an issue but I'm hashing the result so it causing my hash to change.

<?xml version="1.0"?>
<License xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    ...
</License>

Assuming you are just letting the xml serializer handle it itself currently: You may well be able to achieve the result you are after by implementing the IXmlSerializable interface in your classes. IXmlSerializable

That way you can explicitly define what text gets outputted to the XmlWriter.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM