Having issue Deserializing array from an XML string

Posted by LeeHull on Stack Overflow See other posts from Stack Overflow or by LeeHull
Published on 2010-05-18T17:45:44Z Indexed on 2010/05/18 17:50 UTC
Read the original article Hit count: 320

Filed under:
|
|
|

I'm having issues trying to deserializing my xml string that was from a dataset..

Here is the XML layout..

<DataSet>
  <User>
    <UserName>Test</UserName>
    <Email>[email protected]</Email>
    <Details>
      <ID>1</ID>
      <Name>TestDetails</Name>
      <Value>1</Value>
    </Details
    <Details>
      <ID>2</ID>
      <Name>Testing</Name>
      <Value>3</Value>
    </Details
  </User>
</DataSet>

Now I am able to deserialize the "UserName" and "Email" when doing

public class User
{
    public string UserName {get;set;}
    public string Email {get;set;}
    public Details[] Details {get;set;}
}
public class Details
{
    public int ID {get;set;}
    public string Name {get;set;}
    public string Value {get;set;}
}

This deserializes fine when I just get the user node, the Details isnt null but has no items in it..

i know I am suppose to have between all the details but I rather not modify the XML, anyways to get this to deserialize properly without recreating the XML after I get it?

© Stack Overflow or respective owner

Related posts about Xml

Related posts about deserialization