XmlSerializer を使用して、単純なテキストまたはサブ要素を含む要素を文字列に逆シリアル化する方法はありますか?
XML サンプル:
<Attribute>
<AttributeValue xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="xs:string">thisistext</AttributeValue>
<AttributeValue>
<e:Authorities xmlns:e="urn:dummy">
<e:Authority>ORG_CHIEF</esia-encoder:Authority>
</e:Authorities>
</AttributeValue>
</Attribute>
C# プロパティ:
[XmlElement("AttributeValue", IsNullable = true)]
public string[] AttributeValue { get; set; }
最初の AttributeValue の逆シリアル化は成功しますが、次の逆シリアル化は失敗します。ReadElementString メソッドは単純なコンテンツまたは空のコンテンツを想定しているため、不思議ではありません。シリアライザーに「この要素の内容を文字列に入れる」ように指示する方法を探しています。