2013-01-23 3 views
7

다음 xsi : schemaLocation을 직렬화 된 클래스에 추가하려면 어떻게해야합니까? 여기직렬화 된 객체에 xsi : 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; } 

} 

내가 얻을 VS에서 개체에 XML을 역 직렬화합니다. " 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

대단한 AttributeName은 (내가 성공하지 못한 ElementName을 사용하고 있었다는) 단서입니다. 그리고 NameSpace는 선언 된 xmlns : xsi와 일치해야합니다. 고마워요! –

관련 문제