无法将元素[MyClass]转换为XML [英] Failed to convert the element [MyClass] to XML

查看:122
本文介绍了无法将元素[MyClass]转换为XML的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个代码将一个对象转换为xmldocument但是在这样做时我得到了这个错误



代码是返回xmldocument如下:



I have this code which converts an object to xmldocument but while doing that i get this error

The code is which returns the xmldocument is below :

public static XmlDocument ToXmlDocument(this MyClass myclass)
        {
            var result = new XmlDocument();
            var xml = myclass.ToXml(true, Formatting.Indented, EOLType.CRLF, Helpers.XmlSerializationContext());
            result.LoadXml(xml);
            return result;
        }





当我将对象转换为xml时,我认为有些东西是可疑的



有人可以建议那里有什么问题



最好,

Hg



I think something is fishy there when i am converting object to xml

can someone please suggest what is wrong in there

Best,
Hg

推荐答案

我无法理解你为什么使用某些第三方扩展来将对象序列化为XML,但如果这是一个要求,那就去询问第三方的支持!

如果您可以选择自己的方式,那么使用XML序列化(和反序列化)的简单.NET方式就可以了。

从这里开始阅读:XML序列化和反序列化:第1部分 [ ^ ]
I can't understand why you are using some 3rd party extension to serialize an object to XML, but if this is a requirement then go and ask the 3rd party for support!
If you can choose your way, than you be better with the simple .NET way of XML serialization (and deserialization)...
Start reading here: XML Serialization and Deserialization: Part-1[^]


这篇关于无法将元素[MyClass]转换为XML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆