2011-09-11 6 views
3

XML을 가질 수 있습니까? 그 중 하나의 요소에는 혼합 된 내용이 포함되어 있으며 혼합 요소의 텍스트는 string 대신 사용자 지정 개체로 역 직렬화됩니까? textType로서 직렬화 될 텍스트 항목을 기대C# XML 혼합 콘텐츠의 텍스트를 사용자 지정 개체로 deserialize 하시겠습니까?

[XmlText(typeof(textType))] 
    [XmlElement("query", typeof(templateBodyQuery))] 
    [XmlElement("expand", typeof(expandType))] 
    [XmlElement("insert", typeof(expandTypeInsert))] 
    public object[] Items { get; set; } 

하지만 나는 'textType' cannot be used as 'xml text' 오류 :

나는이 시도.

이 내 textType 클래스입니다 : 당신은 XMLTEXT에 대한 비 기본 형식을 사용할 수 없습니다

public class textType 
{ 
    [XmlText] 
    public string Value { get; set; } 
} 

답변

0

. 또한 단일 노드 아래에 XmlText 및 XmlElements를 가질 수 없으므로 XML이 어떻게 구성되는지 이해할 수 없습니다.

[XmlElement("textType",typeof(textType))] 
[XmlElement("query", typeof(templateBodyQuery))] 
[XmlElement("expand", typeof(expandType))] 
[XmlElement("insert", typeof(expandTypeInsert))] 
public object[] Items { get; set; } 

역 직렬화하는 :

<Test> 
    <textType>example</textType> 
    <query>...</query> 
    <expand>...</expand> 
</Test> 

Items 배열의 시작과에서 textType 개체가있는 클래스 Test

나는 이것이 당신이 뭘 하려는지 생각 "예의"Value

관련 문제