0

I need to Serialize an object which has string field, the value of the string is " Applicable", when the object it is serialized i get " Applicable". how do i escape & and anyone knows what value ("&#4") it is and correct way to produce it.

I know it is Illegal XML, but that's how the application accepts.

vrs
  • 381
  • 2
  • 12
  • Trying to produce something that isn't XML basically means you have to use tools that can handle non-XML. Most XML libraries can't. – Michael Kay May 28 '20 at 07:42

1 Answers1

0

I have used IXmlSerializable interface to create custom data type ad described in this

https://stackoverflow.com/a/38109865/3575100

public class CustomDataType : IXmlSerializable
{

    public string Value { get; set; }
    public XmlSchema GetSchema()
    {
        return null;
    }

    public void ReadXml(XmlReader reader)
    {
       Value = reader.ReadInnerXml();
    }

    public void WriteXml(XmlWriter writer)
    {
        writer.WriteRaw(Value);
    }
}
vrs
  • 381
  • 2
  • 12