0

I have a class with an XMLElement of type Message:

public class TimeBlock
{
  public TimeBlock()
  {
    info = new Message();
  }
  [XmlElement("ReceivedInfo")]
  public Message info { get; set; }
}

which is a self-defined class containing XMLElement of type List.

    [XmlElement("ReformedLine")]
    public List<XCData> reformedBody { get; set; }

where "line" is a string. In the main method I have:

    XCData reformedLine = new XCData(line);
    timeBlock.info.reformedBody.Add(reformedLine);

But after running it throws the exception of:

System.InvalidOperationException' occurred in System.Xml.dll

How can I solve this? Generally, how should I wrap a part of Data I want to serialize into CDATA (before forming the XML document and having access to the nodes)?

EyeDa
  • 1
  • 1
    Possible duplicate of [How do you serialize a string as CDATA using XmlSerializer?](http://stackoverflow.com/questions/1379888/how-do-you-serialize-a-string-as-cdata-using-xmlserializer) – Sinatr May 19 '16 at 08:23
  • No it's not. When I have a single variable of type string the link you mentioned works. But when I have a list defined, it doesn't work anymore. @Sinatr – EyeDa May 19 '16 at 08:27

0 Answers0