XmlSerializer and xsd: list

Is there any ready-made way to handle <xsd:list> in the XmlSerializer?

In my case, I got a double list, something like this:

 <xs:complexType name="PositionType"> <xs:simpleContent> <xs:extension base="doubleList"> </xs:extension> </xs:simpleContent> </xs:complexType> <xs:simpleType name="doubleList"> <xs:list itemType="xs:double"/> </xs:simpleType> <xs:element name="Test" type="PositionType"/> 

An example might look like this: <pos>10.3 20.2 -2.4</pos>

I tried to make xsd.exe reveal some secrets, but it generated this ... which failed:

 private double[] textField; [System.Xml.Serialization.XmlTextAttribute()] public double[] Text { get { return this.textField; } set { this.textField = value; } } 

An exception:

  System.InvalidOperationException: Member 'Text' cannot be encoded using the XmlText attribute. You may use the XmlText attribute to encode primitives, enumerations, arrays of strings, or arrays of XmlNode. 

Please note that I am using existing schemes and cannot influence the design.

+4
source share

Source: https://habr.com/ru/post/1382454/


All Articles