2013-01-23 9 views
7

मैं निम्नलिखित xsi कैसे जोड़ सकता हूं: एक serialized कक्षा में schemaLocation?xsi कैसे जोड़ें: serialized ऑब्जेक्ट के लिए schemaLocation

<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"> 

यहाँ मैं अब तक क्या किया है है:

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; } 

} 

जब मैं वी.एस. में वस्तु के लिए एक्सएमएल deserialize मैं:

{ "विधि या कार्रवाई लागू नहीं किया गया है। " xsi:: - XML दस्तावेज़ (5, 44) में कोई त्रुटि है यह वास्तव में लाइन के लिए अंक schemaLocation = "http://ddex.net/xml/2010/ern-main/32 http://ddex.net/xml/2010/ern-main/32/ern-main.xsd"

उत्तर

8

soultion :

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

ग्रेट, विशेषता नाम सुराग है (मैं कोई सफलता के साथ एलिमेंटनाम का उपयोग कर रहा था)। और नामस्थान को xmlns से मेल खाना चाहिए: xsi घोषित किया गया। आपका बहुत बहुत धन्यवाद! –

संबंधित मुद्दे