xmlns=''> was not expected.

S

Shailendra Batham

Hi guys,Does any1 know what this error is all about, what I am trying to do is deserialize a XML, below is my code, let me know what I am doing wrongpublic class test{xin = "<?xml version='1.0' encoding='UTF-8'?><InSession><PassWord>foo</PassWord><UserName>[email protected]</UserName></InSession>";XmlSerializer serializer = new XmlSerializer(typeof(cXmlBS));XmlTextReader tr = new XmlTextReader(new System.IO.StringReader(xin));cXmlBS cx = (cXmlBS)serializer.Deserialize(tr);tr.Close();}public class cXmlBS{public String PassWord;public String UserName;}System.InvalidOperationException: There is an error in XML document (1, 40). ---> System.InvalidOperationException: <InSession xmlns=''> was not expected.
at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReader1.Read4_cXmlBS()
--- End of inner exception stack trace ---
at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle)
at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader)
at BathamWS.LoginService.BeginSession(String xin) in c:\inetpub\wwwroot\bathamws\loginws.asmx.cs:line 62
help is appreciated, thanksshailendra batham
 
S

Stronzo

Apply XmlRoot attribute to your class:

[XmlRoot("InSession")]public class cXmlBS{public String PassWord;public String UserName;}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top