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?
I verified the object is not having them and also the serialization method is working in other part of my code.
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()); }