There's a syntax error in your XML: the
<TRANSACTION>
element is self-closing, but it also has a closing tag.
Quote:
The 'EXPORT_HEADER' start tag on line 2 position 2 does not match the end tag of 'TRANSACTION'. Line 4, position 5.
Once that's fixed, your
"What I have tried" code works to deserialize the XML correctly. You don't need the
DataType
and
IsNullable
attributes on the
ContractData
's
XmlRoot
attribute, and you don't need the
XmlRoot
attribute on the
TRANSACTION
class; but they don't affect the deserialization.
You're only seeing one value written to the console because there is only one value in your XML, and because you're only displaying the first value. If you want to display all values, you'll need to use a loop.
item = (ContractData)serializer.Deserialize(reader);
foreach (TRANSACTION transaction in item.TRANSACTION)
{
Console.Write("{0}\t{1}\t", transaction.Term, transaction.mediatype_code);
}