tags:

views:

25

answers:

1

Hi

I have a xml file that looks like this :

<?xml version="1.0" encoding="utf-8"?>
<config>
 <node id="1" />
</config>

Now I try to deserialize it, but always get the error :

<config xmlns=''> was not expected

Anyone how to fix this ? I dont have any control over the xml.

Thanx

A: 

Why not just load it in as a DOM (e.g. using XmlDocument or XDocument) and extract the data yourself? Assuming it wasn't saved with XmlSerializer, there's no point in trying to deserialize it that way.

EDIT: It would help if you'd give us some background here. If this isn't a valid XmlSerializer output, what is it? Was it originally a valid file, but something has stripped out the namespaces? If so, what else has it done?

You may well be able to get away with just reapplying the namespace everywhere yourself (to every element) although that may be annoying do. Currently we can't really tell though.

Jon Skeet
I just posted an example, the file is actually pretty big and I have to use the XmlSerializer for deserialize.
eemceebee
@eemceebee: *Why* do you have to use `XmlSerializer`? If it's not a valid output from `XmlSerializer`, why would you try to use that to deserialize?
Jon Skeet