XML序列化问题 - 尝试列出属性列表 [英] XML Serialization problem - trying to make a list of atributes

查看:75
本文介绍了XML序列化问题 - 尝试列出属性列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我正在尝试创建一个特定元素的属性列表。

I'm trying to create a list of atributes to an especific element.

我试过了字典,列表,数组,集合等,但没有成功。

I've tried dictionary, list, array, collection and so on, but without success.

我创建了一个类(如下所示),我想生成下面的结果:

I've created a class (as shown below) and i want to produce the result below:

------------------------------------------- ---------

----------------------------------------------------

Public Class clsTest



    Public lst As New Dictionary(Of String,String)
$


End Class

Public Class clsTest

    Public lst As New Dictionary(Of String, String)

End Class

'--------- -----------------------------------------

'--------------------------------------------------

暗淡  obj as new clsTest

Dim  obj as new clsTest

obj.lst.append(" atrib1"," value1")

obj.lst.append("atrib1","value1")

obj.lst.append(" atrib2"," value2")

obj.lst.append("atrib2","value2")

 

'----------------- ------------------------------

'-----------------------------------------------

结果应为:

< clsTest atrib1 =" value1" atrib2 = QUOT;值2" />

<clsTest atrib1="value1" atrib2="value2" />

 

有任何建议吗?

谢谢。

Augusto

 

推荐答案

我认为最接近的是 XmlAnyAttributeAttribute 类。   http://msdn.microsoft.com/en-us/library/ system.xml.serialization.xmlanyattributeattribute.aspx
 基本上你需要提供XmlAttribute []类型的成员字段/属性。
I think the closest is the XmlAnyAttributeAttribute class.  http://msdn.microsoft.com/en-us/library/system.xml.serialization.xmlanyattributeattribute.aspx.  Basically you need to provide a member field/property of type XmlAttribute[].


这篇关于XML序列化问题 - 尝试列出属性列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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