开发者

How to deserialize an xml that has no namespace, etc...?

I have a xml file that looks like this 开发者_Python百科:

<?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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜