Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Leading Question Mark with serializer.Serialize()
Message
Information générale
Forum:
ASP.NET
Catégorie:
XML
Divers
Thread ID:
01005829
Message ID:
01005964
Vues:
17
After digging a little further I have determined that the first 3 bytes in the textWrite.BaseStream _buffer are 239, 187 and 191. After this they continue on with 60, 63, 120, 109, 108, etc. which is
<?xml...
Why the first 3 bytes of data? what am I missing?

Thanks,
Paul


>I can't for the life of me determine why the xml returned from serializer.Serialize() has a leading question mark associated with it.
>
>I have the following code:
>
>OrderNumber = DB.RSFieldInt(rs,"OrderNumber");
>Order ord = new Order(OrderNumber);
>System.Type[] extraTypes = new System.Type[1];
>extraTypes[0] = typeof(CartItem);
>
>MemoryStream memoryStream = new MemoryStream();
>XmlSerializer serializer = new XmlSerializer(typeof(Order),extraTypes);
>XmlTextWriter textWriter = new XmlTextWriter(memoryStream, Encoding.UTF8);
>serializer.Serialize(textWriter,ord);
>memoryStream = (MemoryStream)textWriter.BaseStream;
>xml = Common.UTF8ByteArrayToString(memoryStream.ToArray());
>
>
>I can't load the xml into a browser because it has the leading question mark:
>
>?<?xml version="1.0" encoding="utf-8"?><Order xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3...
>
>
>of course after I remove the leading question mark by going into notepad and deleting it, everything works fine.
>
>
>Can anyone help me here?
>
>Thanks,
>Paul
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform