Reputation: 57
Here is my code
private void parseCurrentPersonData(string aRespString)
{
// converting string to stream
byte[] byteArray = Encoding.UTF8.GetBytes(aRespString);
MemoryStream personXml = new MemoryStream(byteArray);
if (personXml != null)
{
personXerializer = new XmlSerializer(typeof(person));
currentPerson = (person)personXerializer.Deserialize(personXml);
updateUI();
}
}
and a class
[XmlRoot("Root")]
public class person
{
[XmlElement("first-name")]
public string FirstName { get; set; }
[XmlElement("last-name")]
public string LastName { get; set; }
[XmlElement("headline")]
public string Headline { get; set; }
[XmlElement("headline")]
public string Interests { get; set; }
}
I am getting error
An exception of type 'System.InvalidOperationException' occurred in System.Xml.Serialization.ni.dll but was not handled in user code
on this line
personXerializer = new XmlSerializer(typeof(person));
Please help
Upvotes: 0
Views: 64
Reputation: 289
It might be because you have two XmlElements that have the same name?
Upvotes: 4