xmlns="> was not expected
- by Anthony Shaw
OK. I'm trying to work on communicating with the Pivotal Tracker API, which only returns data in an XML format. I have the following XML that I'm trying to deserialize into my domain model.
<?xml version="1.0" encoding="UTF-8"?
<stories type="array" count="2" total="2"
<story
<id type="integer"2909137</id
<project_id type="integer"68153</project_id
<story_typebug</story_type
<urlhttp://www.pivotaltracker.com/story/show/2909137</url
<current_stateunscheduled</current_state
<description</description
<nameTest #2</name
<requested_byAnthony Shaw</requested_by
<created_at type="datetime"2010/03/23 20:05:58 EDT</created_at
<updated_at type="datetime"2010/03/23 20:05:58 EDT</updated_at
</story
<story
<id type="integer"2909135</id
<project_id type="integer"68153</project_id
<story_typefeature</story_type
<urlhttp://www.pivotaltracker.com/story/show/2909135</url
<estimate type="integer"-1</estimate
<current_stateunscheduled</current_state
<description</description
<nameTest #1</name
<requested_byAnthony Shaw</requested_by
<created_at type="datetime"2010/03/23 20:05:53 EDT</created_at
<updated_at type="datetime"2010/03/23 20:05:53 EDT</updated_at
</story
</stories
My 'story' object is created as follows:
public class story
{
public int id { get; set; }
public int estimate { get; set; }
public int project_id { get; set; }
public string story_type { get; set; }
public string url { get; set; }
public string current_state { get; set; }
public string description { get; set; }
public string name { get; set; }
public string requested_by { get; set; }
public string labels { get; set; }
public string lighthouse_id { get; set; }
public string lighthouse_url { get; set; }
public string owned_by { get; set; }
public string accepted_at { get; set; }
public string created_at { get; set; }
public attachment[] attachments { get; set; }
public note[] notes { get; set; }
}
When I execute my deserialization code, I receive the following exception:
Exception:
There is an error in XML document (2, 2).
Inner Exception:
<stories xmlns='' was not expected.
I can deserialize the individual stories just fine, I just cannot deserialize this xml into an array of 'story' objects
And my serialization code
var byteArray = Encoding.ASCII.GetBytes(value);
var stream = new MemoryStream(byteArray);
var deserializedObject = new XmlSerializer(typeof (story[])).Deserialize(stream)
Does anybody have any ideas?