English 中文(简体)
Xml 序列化为具有属性的元素
原标题:Xml serialization as elements with properties

我通常使用 DataSet. GetXml () 方法对数据集进行序列化, 我遇到了一个问题: 是否有一种简单的方法可以使用属性而不是元素来对数据集对象进行序列化? 例如, GetXml () 方法可以从数据集中生成 :

<foo>
<height>bleem</height>
<color>yurple</color>
</foo>

但是,我想看到一些东西,比如:

<foo height="bleem" color="yurple" />

我意识到财产导向方法存在限制,但我正在使用数据库数据,所以独特性不应该是一个问题。我一直在调查SO,但我找不到任何关于这个问题的线索。任何XML专家都有什么想法吗?

最佳回答

我不是XML专家 我只是在电视上玩

我将使用"http://msdn.microsoft.com/en-us/library/system.data.datacolumn.colummapping%28v=vs.100%29.aspx" rel=“nofolt”>Datacolumn.Column Mapping 属性 来确定如何绘制您的列。 对于您想要绘制为 XML 属性的所有列, 请设定其 ColumnMapping 等于 < code> MappingType.Attrait 。

问题回答

暂无回答




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签