本文介绍了[UWP] [VB]使用从XmlElement继承的自定义类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我有一个XML文件,其中包含我想要转换为继承自XmlElement的我的自定义类的元素。例如,我的XML可能包含一个元素,例如: < Group transformation =" 1,0,0,0,1,0,0,0,1,0 ,0,0"枢轴= QUOT; 0,0,0" partRefs =" 1,0" /> 当我加载XML(我使用XmlDocument.LoadXml)时,这被解析为的XmlElement。我希望它被解析为我的自定义类的一个实例,它继承自XmlElement,例如: Public Class Group:Inherits XmlElement:Implements IXmlSerializable 此类包含与transformation,pivot和partRefs属性匹配的属性。是否有一种简单的方法可以让.NET将其解析为我的自定义类?有没有更好的方法来做这种事情?谢谢。 Nathan Sokalski [email protected] http://www.nathansokalski.com/解决方案 我有一个XML文件,其中包含我想要转换为从XmlElement继承的自定义类的多个元素。例如,我可能将以下内容作为我的XmlDocument的一部分: < Group transformation =" 1,0,0,0,1,0,0,0,1 ,0,0,0"枢轴= QUOT; 0,0,0" partRefs =" 1,0" /> XmlDocument.LoadXml方法会将此转换为XmlElement(这是我所期望的)。但是,我希望将它转换为我的自定义类,声明为: 公共类组:继承XmlElement:实现IXmlSerializable 此类包含与transformation,pivot和partRefs属性匹配的属性。有没有办法让匹配的XmlElements转换为我的自定义类继承自XmlElement而不手动执行?感谢。 I have an XML file that contains elements that I would like to convert to a custom class of mine that inherits from XmlElement. For example, my XML might contain an element such as:<Group transformation="1,0,0,0,1,0,0,0,1,0,0,0" pivot="0,0,0" partRefs="1,0"/>When I load the XML (which I do using XmlDocument.LoadXml), this is parsed as an XmlElement. I would like it to be parsed as an instance of a custom class of mine that inherits from XmlElement such as:Public Class Group : Inherits XmlElement : Implements IXmlSerializableThis class contain properties matching the transformation, pivot, and partRefs attributes. Is there an easy way to get .NET to parse this as my custom class? Is there a better way to do this kind of thing? Thanks.Nathan Sokalski [email protected] http://www.nathansokalski.com/ 解决方案 I have an XML file that contains multiple elements that I want to convert to custom classes that inherit from XmlElement. For example, I might have the following as part of my XmlDocument:<Group transformation="1,0,0,0,1,0,0,0,1,0,0,0" pivot="0,0,0" partRefs="1,0"/>The XmlDocument.LoadXml method would convert this to an XmlElement (which is what I would expect). However, I want it to be converted to a custom class of mine declared as:Public Class Group : Inherits XmlElement : Implements IXmlSerializableThis class contains properties matching the transformation, pivot, and partRefs attributes. Is there a way to get the matching XmlElements converted to my custom class that inherits from XmlElement without doing it manually? Thanks. 这篇关于[UWP] [VB]使用从XmlElement继承的自定义类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 10-21 10:26