如何读取用逗号分隔的数据到datagridview(XML文件) [英] How to I read data separated by comma into datagridview (XML file)

查看:85
本文介绍了如何读取用逗号分隔的数据到datagridview(XML文件)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个文件,我想将嫌疑人的数据读入数据网格视图但是有多行...有什么可能吗?





<?xml version =1.0encoding =utf-8?>

< types>

< type_name>

< id> 4

< suspects> abc,abcd







我尝试了什么:



我试过循环但是没有用:/

I have this file and I want to read the suspects data into datagrid view but in multiple rows ... is there any possible way ??


<?xml version="1.0" encoding="utf-8"?>
<types>
<type_name>
<id>4
<suspects>abc,abcd



What I have tried:

I tried looping but it didn't work :/

推荐答案

没有内置方法:你必须手动完成。

使用XML阅读器处理XML数据,然后处理返回的DataTable的每一行使用string.Split来分解你的数据。



但说实话,无论谁设计你的文件格式都应该被拍摄。没有充分的理由将CSV数据混合到XML文件中:两种格式都可以在没有它的情况下完成所需的工作。
There is no built in method: you will have to do it manually.
Use an XML reader to process the XML data, then process each row of the returned DataTable using string.Split to break up your data.

But to be honest, whoever designed your file format should be shot. There is no good reason for "mixing" CSV data into an XML file: both formats can do what you need without it.


这篇关于如何读取用逗号分隔的数据到datagridview(XML文件)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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