
//将DataSet转换为xml文件
public static void ConvertDataSetToXMLFile(DataSet xmlDS,string xmlFile)
{
MemoryStream stream = null;
XmlTextWriter writer = null;
try
{
stream = new MemoryStream();
//从stream装载到XmlTextReader
writer = new XmlTextWriter(stream, Encoding.Unicode);
//用WriteXml方法写入文件.
xmlDS.WriteXml(writer);
int count = (int)stream.Length;
byte[] arr = new byte[count];
stream.Seek(0, SeekOrigin.Begin);
stream.Read(arr, 0, count);
//返回Unicode编码的文本
UnicodeEncoding utf = new UnicodeEncoding();
StreamWriter sw = new StreamWriter(xmlFile);
sw.WriteLine("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
sw.WriteLine(utf.GetString(arr).Trim());
sw.Close();
}
catch( System.Exception ex )
{
throw ex;
}
finally
{
if (writer != null) writer.Close();
}
}
}
public void SingleTable2XML()
{
//Create an ODBC connection to the database. Here it is an Access file
OdbcConnection conn = new OdbcConnection("DSN=XmlDb_NorthWind");
//Create a DataSet with a name "XmlDb"
DataSet dataset = new DataSet("XmlDb");
//Create a DataAdapter to load data from original data source to the DataSet
OdbcDataAdapter adapter = new OdbcDataAdapter();
adapter.SelectCommand = new OdbcCommand("SELECT * FROM Customers", conn);
adapter.Fill(dataset, "Customers");
//Create a virtual XML document on top of the DataSet
XmlDataDocument doc = new XmlDataDocument(dataset);
//Output this XML document
doc.Save(Console.Out);
//NUnit test to confirm the result is exactly what we expect
Assert.AreEqual("XmlDb", doc.DocumentElement.LocalName);
Assert.AreEqual("Customers", doc.DocumentElement.FirstChild.LocalName);
}
一、XML与DataSet的相互转换的类 using System; using System.Collections.Generic; using System.Text; using System.Data; using System.IO; using System.Xml; namespace XmlDesign { class XmlDatasetConvert...
<music> <song> <artist>The Chi-lites</artist> <genre>Soul</genre> <album>A lonely man&l...
最近在跑SSD和Faster R-CNN深度学习代码,下载了一些数据集,但是这些数据集标签文件不是xml格式文件,而是yaml文件,虽然网上有在线转化的工具,但是这种做法对我来说显然是很低效率的。为了满足要求自己写了转化的...
笔者参考一个博主的方法,实现了将json文件转化为xml文件,亲测可用,并且在labelimg标注软件中可以查看转换后的标注结果。 参考原文链接:https://blog.csdn.net/u013066730/article/details/103007285 笔者将转换...
转:... 下面给出两个实现XML数据转成DataSet的两个方法。第1种://通过传入的特定XML字符串,通过 ReadXml函数读取到DataSet中。protected static DataSet GetDataSetByXml(string xmlData){ try...
DataSet与XML互转辅助类
1,转String->//将DataSet转换为xml字符串 public static string ConvertDataSetToXMLFile(DataSet xmlDS, Encoding encoding) { MemoryStream stream = null; XmlTextWriter writer = nul...
1.主要实现代码如下: PEISWS_Report_Print p1 = new PEISWS_Report_Print(); //webservice string sGroupResult = p1.... //调webservice返回xml文件 if (!string.IsNullOrEmpty(sGroupResult)) { ...
在使用tensorflow做目标检测时,通过labelimg标注的数据为xml格式的labels,需要将其转化成record格式的文件,才能在tensorflow框架下训练。 该教程主要介绍从将xml格式转化成record格式的方法。 需要2个python...
参考链接:点击打开链接我自己的数据集格式为filename lable xmin ymin xmax ymax1 通过别的模板转换VOC数据集的xml格式为:<annotation> <folder>VOC2007</folder> &...
一:DataSet/Datatable读取xml文件。 这个很简单了,C#直接提供了api,我们直接调用就可以了:DataSet ds = new DataSet(); ds.ReadXml(filePath + fileName);当然我们要的可能不是DataSet或是D
using System; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Data;...using System.Data.OleDb...using System.Xml; using System.IO; using System.Xml.Schema; namespac...
//获取xml数据,并转换为datasetpublic static DataSet getConfig(string strXmlPath){ string filePath = GetPhysicalPath(); DataSet ds= ConvertXMLFileToDataSet(GetXmlFullPath(filePath)); return ds;} //将...
如何将多个DataTable添加到指定的DataSet中 事件起因:从数据库中,查询多个dataTable,现在想一下子返回多个table,所以就想到用DATASET,遇到下面的两个现象,现在记录下,做个参考。
txt_to_xml程序如下: # -*- coding: utf-8 -*- import os,shutil import cv2 from lxml.etree import Element, SubElement, tostring def txt_xml(img_path,img_name,txt_path,img_txt,xml_path,img_xml): #读取...
XMl文件转JSON字符串: 1.1Maven引入依赖 <!-- https://mvnrepository.com/artifact/dom4j/dom4j --> <dependency> <groupId>dom4j</groupId> <artifactId>dom4j</artifactId...
准备Yolo数据集的时候,使用工具标注出来坐标可能是归一化之后的坐标,如果想要得到图片上的原始坐标则需要通过公式转化,下面我详细分析一下图片原始坐标和归一化坐标之间的关系,之后不论需要哪种坐标都能很轻松的...
今天接到一个需求,公司的错误信息会被保存在xml文件中,我需要统计一下所有错误信息。成百上千份Error_Log肯定是程式解决了。 如下图,为Error_Log文件 using System.Xml; DataTable dt = new DataTable(); for ...
数据转换实在是个烦人的工作,被折磨了很久...XML文件内容长什么样 COCO的数据格式长什么样 XML如何转化成COCO格式 VOC XML长什么样? 下面我只把重要信息题练出来,如下所示: 文件夹目录 图片名.jpg path_t...
在前面的博客中介绍了如何将labelme标注的json文件转换为labelimg标注的xml文件:【json&xml】labelme标注的json文件转化成labelimg储存的xml文件。 笔者在具体使用转换后的xml文件时发现一个问题:我们知道在...
#region xml文件内容转化为DataSet /// /// xml文件内容转化为DataSet /// /// /// public static DataSet XmlToDataSet(string XmlFilePath) {
#region //将DataTable转化为XML private string ConvertDataTableToXML(DataTable xmlDS) { MemoryStream stream = null; XmlTextWriter writer = null; try {
<!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--><script type="text/javascript"
Sql表查询得到的DataTable要转化成XML,就顺便写个测试的例子, 实现的功能 利用反射实现了DataTable,实体对象,XML的互转。 达到的效果 Code: sql if exists (select * from sysobjects where id = OBJECT_...
将.xlsx文件读取到.xml文件 var fileName = Application.StartupPath + @"\Sample.xlsx"; var connectionString = string.Format("Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0}; Extended Properties=Exce
在完成目标检测任务时,常用的标注数据格式是voc数据集的xml格式和coco数据集的json格式,有时候,我们需要完成标注信息格式的变化,下面主要是对我自己的过程做个记录。 首先需要明白自己的原始标注信息的样子,...
using System; using System.Data; using System.Configuration; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls...using ...
XmlDatasetConvert 该类提供了四...2、将xml文件转换为DataSet 3、将DataSet转换为xml对象字符串 4、将DataSet转换为xml文件 XmlDatasetConvert.cs using System; using System.Collections.Generic; using Sys
将一个dataSet转换成一个list 所以就需要取得DataSet里面的一个table表 因为list是IList类型的,所以就要实例化一个list 【IList<T> list=new List】 这时候我就要取得T类型的所有公有成员,来接收table表的字段...
之前我用 LabelImg (下载以及用法见 https://github.com/tzutalin/labelImg) 标图片时格式选错了,于是写了个脚本将YOLO格式的.txt文件转换为PascalVOC格式的.xml文件。其实就是将.txt中的坐标转换一下,再对照着...