How to add xsi: schemaLocation for serialized object

How to add the following xsi: schemaLocation class to a serialized class?

<ern:NewReleaseMessage xmlns:ern="http://ddex.net/xml/2010/ern-main/32" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" LanguageAndScriptCode="en" xsi:schemaLocation="http://ddex.net/xml/2010/ern-main/32 http://ddex.net/xml/2010/ern-main/32/ern-main.xsd" MessageSchemaVersionId="2010/ern-main/32"> 

Here is what I have done so far:

 public class NewReleaseMessage { [XmlAttribute] public string LanguageAndScriptCode { get; set; } [XmlAttribute("schemaLocation", Namespace = "http://ddex.net/xml/2010/ern-main/32")] public string schemaLocation = "http://ddex.net/xml/2010/ern-main/32 http://ddex.net/xml/2010/ern-main/32/ern-main.xsd"; [XmlAttribute] public string MessageSchemaVersionId { get; set; } [XmlElement()] public MessageHeader MessageHeader { get; set; } } 

When I deserialize the xml for an object in VS, I get:

{"Method or operation not implemented." There is an error in the XML document (5, 44). This actually points to the line: xsi: schemaLocation = "http://ddex.net/xml/2010/ern-main/32 http://ddex.net/xml/2010/ern-main/32/ern-main. xsd "

+7
source share
1 answer

Soultion:

 [XmlAttribute(AttributeName = "schemaLocation", Namespace = "http://www.w3.org/2001/XMLSchema-instance")] public string schemaLocation { get; set; } 
+8
source

All Articles