c# - Cannot Deserialize xml to List<T> -


im trying deserialize xml response of wcf web service list using xmlserializer fails exception message :there error in xml document (1, 2)

xml:

<arrayofnote xmlns="http://schemas.datacontract.org/2004/07/notebookservice" xmlns:i="http://www.w3.org/2001/xmlschema-instance">   <note>     <author>redouane</author>     <body>test note</body>     <creationdate>2014-01-28t00:00:00</creationdate>     <id>1</id>     <title>hello world</title>   </note> </arrayofnote> 

c#:

public class note {     public int id { get; set; }     public string title { get; set; }     public system.datetime creationdate { get; set; }     public string author { get; set; }     public string body { get; set; } } 

and code wrote deserialize received stream

private httpclient client = new httpclient(); private list<note> notes = new list<note>(); 

. . .

xmlserializer serializer = new xmlserializer(typeof(list<note>)); var responsedata = await response.content.readasstreamasync(); list<note> list = serializer.deserialize(responsedata) list<note>; 

please help!

change creation of serializer follows , should work.

xmlserializer serializer = new xmlserializer(typeof(list<note>),                                  new xmlrootattribute("arrayofnote") {                                      namespace = "http://schemas.datacontract.org/2004/07/notebookservice"                                  }); 

Comments

Popular posts from this blog

php - regexp cyrillic filename not matches -

c# - OpenXML hanging while writing elements -

sql - Select Query has unexpected multiple records (MS Access) -