Serialization adds some wierd characters "d3p1:" to return string

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Sri13
    New Member
    • Sep 2010
    • 11

    Serialization adds some wierd characters "d3p1:" to return string

    A third party web service method returns an object which we try to serialize into a string. When I use the following method to serialize the object, I see some text "d3p1:", "d4p1" prefixed with each tag and attribute. What is this and why does it add these characters?

    Code:
    public static string SerializeObject(Object pObject)
    {
      MemoryStream memoryStream = new MemoryStream();
      XmlSerializer xs = new XmlSerializer(pObject.GetType());
      XmlTextWriter xmlTextWriter = new XmlTextWriter(memoryStream, Encoding.ASCII);
      XmlQualifiedName[] blankNS = new XmlQualifiedName[] { new XmlQualifiedName("", "") };
      XmlSerializerNamespaces blank = new XmlSerializerNamespaces(blankNS);
      xs.Serialize(xmlTextWriter, pObject, blank);
      memoryStream = (MemoryStream)xmlTextWriter.BaseStream;
      UTF8Encoding encoding = new UTF8Encoding();
      return encoding.GetString(memoryStream.ToArray());
    }
    I verified the object is not having them and also the serialization method is working in other part of my code.
Working...