Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

problem with desirialization of a string. Please help...

Status
Not open for further replies.

drey8

Programmer
Aug 31, 2004
17
US
I have a problem with Deserializing a xml string.
I have a object I serialize:

MemoryStream buffer = new MemoryStream();
System.Xml.Serialization.XmlSerializer xmlSerializer = new System.Xml.Serialization.XmlSerializer(typeof(myobject));
xmlSerializer.Serialize(buffer, schedule);

if I Deserialize the object after this code line, it works fine. But if I store the xml in code it Deserialize it gives me an error.

XmlDocument doc = new XmlDocument();
doc.Load(buffer);
string xml = doc.OuterXml;
MemoryStream XMLString = new MemoryStream();
byte[] firstString = uniEncoding.GetBytes(XMLString);
buffer.Write(firstString, 0 , firstString.Length);
schedule = (ScheduleDefinition) serializer.Deserialize(buffer);

I need the xml string as a parameter, so i need to be able to convert it back into the object. But I always get the message:
{"There is an error in XML document (1, 426)." }
Any other suggestions to accomplish this?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top