Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Serializing an object to XML
Message
Information générale
Forum:
ASP.NET
Catégorie:
XML
Titre:
Serializing an object to XML
Divers
Thread ID:
01004882
Message ID:
01004882
Vues:
84
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 get the following message:
The XML page cannot be displayed 
Cannot view XML input using style sheet. Please correct the error and then click the Refresh button, or try again later. 


--------------------------------------------------------------------------------

Invalid at the top level of the document. Error processing resource 'file:///C:/aeorder.xml'. Line 1, Position 1 

?<?xml version="1.0" encoding="utf-8"?><Order xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3...
I'm not sure why I get the question mark at the beginning...but I remove that from the file and try to display the file again and then I get:
The XML page cannot be displayed 
Cannot view XML input using XSL style sheet. Please correct the error and then click the Refresh button, or try again later. 


--------------------------------------------------------------------------------

Invalid at the top level of the document. Error processing resource 'file:///C:/aeorder.xml'. Line 1, Position 2403 

<chosenSize /><chosenSizeSKUModifier /><textOption /><weight>0</weight><subscriptionMonths&...
Can anyone help me here?

Thanks,
Paul
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform