绑定任何XML& XSD到DataGridView c# [英] Bind any XML & XSD to DataGridView c#

查看:101
本文介绍了绑定任何XML& XSD到DataGridView c#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个DataGridView,它使用XmlSerializer和一个用于序列化的类,使用XML填充数据。我使用XML模式验证xml。
我想知道是否有一种方法来绑定任何xml与gridview,而不需要使用额外的类进行序列化。
我想能够为应用程序提供一个XML和一个XSD模式进行验证,并且应用程序将自动填充DataGridView,无论什么xml将会收到,我该如何实现?
* XML文件应为简单

解决方案

您可以使用XDocument或XmlDocument类读取XML,以获取所有值。
问题是,你首先必须指定datagridview列,所以首先你必须读取整个xml来获取它包含的所有元素,然后决定你想在表中显示哪一个。


I have a DataGridView which I populate with data from an XML using XmlSerializer and a class that is used for serialization.I validate the xml using an XML schema. I was wondering if there is a way to bind any xml with a gridview without the need to use the extra class for serialization. I would like to be able to feed the application an XML and a XSD schema for validation and the aplication would fill the DataGridView automatically, no matter what xml it would receive, how could I achieve this? *The XML file should be simple.

解决方案

You can read XML using XDocument or XmlDocument class - to get all values. Problem is, that you first have to specify datagridview columns, so first you have to read whole xml to get all elements it contains and then decide which one would you like to show in the table.

这篇关于绑定任何XML& XSD到DataGridView c#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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