jhlim 20240202_2
This commit is contained in:
55
DDUtilityApp/MESDOWNLOADER/XmlToDsConverter.cs
Normal file
55
DDUtilityApp/MESDOWNLOADER/XmlToDsConverter.cs
Normal file
@@ -0,0 +1,55 @@
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.IO;
|
||||
using System.Xml;
|
||||
|
||||
namespace DDUtilityApp.MESDOWNLOADER
|
||||
{
|
||||
|
||||
public static class XmlToDsConverter
|
||||
{
|
||||
public static DataSet ConvertXmlToDataSet(string xmlFilePath)
|
||||
{
|
||||
try
|
||||
{
|
||||
DataSet dataSet = new DataSet();
|
||||
using (StreamReader reader = new StreamReader(xmlFilePath, System.Text.Encoding.UTF8))
|
||||
{
|
||||
dataSet.ReadXml(reader);
|
||||
}
|
||||
return dataSet;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"XML 변환 오류: {ex.Message}");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void PrintDataSet(DataSet dataSet)
|
||||
{
|
||||
if (dataSet == null)
|
||||
{
|
||||
Console.WriteLine("데이터셋이 비어 있습니다.");
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (DataTable table in dataSet.Tables)
|
||||
{
|
||||
Console.WriteLine($"테이블: {table.TableName}");
|
||||
foreach (DataRow row in table.Rows)
|
||||
{
|
||||
foreach (DataColumn column in table.Columns)
|
||||
{
|
||||
Console.WriteLine($"{column.ColumnName}: {row[column]}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// 사용 예제
|
||||
// string xmlPath = "ViewList.xml";
|
||||
// DataSet ds = XmlToDataSetConverter.ConvertXmlToDataSet(xmlPath);
|
||||
// XmlToDataSetConverter.PrintDataSet(ds);
|
||||
Reference in New Issue
Block a user