views:

148

answers:

1
<name>Hello '"world", ü ë &amp%;</name>
<label>''MHU233%;'</label>

XmlSerializer.Deserialize(XmlReader) throws an InvalidOperationException in first case above. Would like to know what is wrong and why latter is ok. XmlReader is created with XmlSettings in constructor where Xml-schema is in SchemaSet.

Thanks!

+5  A: 

You've got an invalid entity there:

&amp%;

It should be:

&amp;

The & says it's the start of an entity. There's no entity called amp% which is why you've got a problem - indeed, percent signs aren't even allowed in entity names. Basically your input XML file is invalid.

Jon Skeet
matti
Yes, `;` marks the end of an entity reference.
Jon Skeet