Groups | Blog | Home
all groups > dotnet xml > march 2006 >

dotnet xml : XML Deserialization Issue


joshjbond NO[at]SPAM gmail.com
3/9/2006 1:21:50 PM
Hello All,
I am having some trouble deserializing some xml into a series of
objects that are part of a web service proxy. I know the XML is valid,
and the objects are up to date (the xml instance doc validates against
the original scheme, which is current with the WSDL). The issue looks
familiar, its identical to one that I have seen when the xmlserializer
chokes on a namespace. In past instances with simple XML docs I was
able to get things working by supplying the Deserialize method a
default namespace, but in this case I have 3 namespaces, and no
default.

Any ideas as to how I would go about solving this?

Here's the line the deserilizer chokes on:

<ns0:Document xmlns:add="http://SomeAddress/Address"
xmlns:con="http://SomeAddress/Contact"
xmlns:ns0="http://SomeAddress/Document">
joshjbond NO[at]SPAM gmail.com
3/9/2006 2:10:48 PM
Interestingly enough I was able to solve this issue through
experimentation. But now I am further confused.
The instance document was missing the encoding declaration, once I
added that

(<?xml version='1.0' encoding='utf-8'?>)

to the top of the instance doc, and included the default namespace in
the serializer declaration

new System.Xml.Serialization.XmlSerializer(typeof(ObjectName),
"http://SomeAddress/Document"))

Everything works. So my new question is

Why? I would feel better if I understood what mysterious inner workings
lead to this resolution.
AddThis Social Bookmark Button