C# .net Deserialization I get an exception.
- by starz26
namespace N1
{
public class InputEntry
{
//FieldName is a class tht is generated from an XSD which has complex type Name and value
private FieldName[] name;
public FieldName[] Name
{
get { return this.Name; }
set { this.Name = value; }
}
}
public class B
{
public void Method1()
{
InputEntry inputEntry = new InputEntry();
inputEntry.Name = "abc";
}
private void Method2(InputEntry inputEntry)
{
System.Xml.Serialization.XmlSerializer serializer = new System.Xml.Serialization.XmlSerializer(typeof(InputEntry));
System.IO.StringWriter inputStr = new System.IO.StringWriter(CultureInfo.InvariantCulture);
serializer.Serialize(inputStr, inputEntry);
string ipEntry = inputStr.ToString();
Method3(ipEntry);
}
private void Method3(string ipEntry)
{
System.Xml.Serialization.XmlSerializer serializer = new System.Xml.Serialization.XmlSerializer(typeof(InputEntry));
System.IO.StringReader inputStr = new System.IO.StringReader(ipEntry);
InputEntry inputEntry = (InputEntry)serializer.Deserialize(inputStr);
}
}
}
I get an exception when deserialising the follwing data(when a client configues data as <FieldName>PRINTLINE00</FieldName> <FieldValue>DENIAL STATE</FieldValue> )
Exception is:
Message: There is an error in XML document (6, 22).
String:
<?xml version="1.0" encoding="utf-16"?>
<InputEntry xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Fields>
<Field>
<FieldName>PRINTLINE00</FieldName>
<FieldValue>DENIAL STATE 217</FieldValue>
</Field>
</InputEntry>