Hello. Serialize the next class in XML
[Serializable] [XmlRoot(Namespace="", ElementName="request")] public class Request { [XmlAttribute("guid")] public Guid Id; [XmlText] public string Body; [XmlIgnore] public DateTime? TimeResponce; } I do object serialization
Request request = new Request(); request.Id = Guid.NewGuid(); request.Body = "<goods><good name=\"Товар 1\"/><good name=\"Товар2\"/></goods>"; var serializer = new XmlSerializer(typeof(Request)); XmlSerializerNamespaces ns = new XmlSerializerNamespaces(); ns.Add(string.Empty, string.Empty); XmlWriterSettings settings = new XmlWriterSettings() { Indent = false, OmitXmlDeclaration = true, DoNotEscapeUriAttributes = true, }; StringWriter writer = new StringWriter(); using (XmlWriter xw = XmlWriter.Create(writer, settings)) { serializer.Serialize(xw, request, ns); } string value = writer.ToString(); At the output, I get a string where the Body field is serialized so that all <and> characters are replaced with the corresponding escape sequences lt; and gt; .
How to serialize an object so that the Body property is serialized without replacing characters into an escape sequence, that is, perceived it as PlainText?
Thank.