0

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

1
  • share your xml structure Sep 20, 2014 at 10:57

1 Answer 1

4

It might be because you have two XmlElements that have the same name?

1
  • Yes!! That solved my issue!! I am hitting myself for not being able to see that!! Sep 20, 2014 at 11:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.