3

During development I've seen xml read errors like this more than once:

TestData.ReadFromXml: xml Deserialize error:There is an error in XML document (2, 2)..

What exactly does (2, 2) refer to? Is it line 2 in the xml file? Line 2, token 2, what?

Are there any debug options I can add to shed more light on the problem?

Edit: here are the first 2 lines:

<?xml version="1.0" encoding="utf-8"?>
<TestSession xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">

So it would be complaining on the 'T' character on the 2nd line? This is a class I just serialized, and it is well formed. When deserializing, I think it doesn't like something in the class... and that might explain why it stops at the T in TestSession. It would be nice if it told you what it didn't like.

3 Answers 3

2

It's (line, character) and begins at 1 (not 0 based).

You should examine the InnerException to get a more precise error message. Looking at your example, it could be something like:

"<TestSession> was not expected."

You can also change the serialized name by applying XmlRootAttribute to your class.

Sign up to request clarification or add additional context in comments.

Comments

1

It's line 2, character 2.

I recommend you open the XML file in Visual Studio and then look at the Errors window to see if it complains at all.

1 Comment

+1. Or notepad2. Or emacs, or etc etc etc. OFten it's a really obvious invalid bit of XML.
-1

Try some xml validation tool to validate your xml file/contents, Do a google, and you'll find some.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.