c# dataSet操作xml文件问题。
如题,,我想用dataGridview 显示xml文件的数据。我的xml文件如下:
<?xml version="1.0" encoding="utf-8" ?>
- <ufinterface sender="011" receiver="u8" roottag="purchasetype" docid="700663566" proc="Query" codeexchanged="N" exportneedexch="N" paginate="0" display="采购类型" family="基础档案" timestamp="0x000000000027B5D6">
- <purchasetype>
<code>01</code>
<name>普通采购</name>
<rstype_code>11</rstype_code>
<bdefau>0</bdefau>
<bpfdefault>0</bpfdefault>
</purchasetype>
- <purchasetype>
<code>02</code>
<name>期初采购</name>
<rstype_code>11</rstype_code>
<bdefau>0</bdefau>
<bpfdefault>0</bpfdefault>
</purchasetype>
</ufinterface>
在c# 中怎么把信息写进dataGridView中呢?一般用dataSet怎么操作xml文件(可能有不同格式的xml)?? --------------------编程问答--------------------
--------------------编程问答--------------------
public static DataSet GetDataSetByXml(string strXmlPath)
{
try
{
DataSet ds = new DataSet();
//读取XML到DataSet
ds.ReadXml(GetXmlFullPath(strXmlPath));
if (ds.Tables.Count > 0)
{
return ds;
}
return null;
}
catch (Exception)
{
return null;
}
}
这样只能找出sender="011" receiver="u8" roottag="purchasetype" docid="700663566" proc="Query" codeexchanged="N" exportneedexch="N" paginate="0" display="采购类型" family="基础档案" timestamp="0x000000000027B5D这些数据而已。下面的数据怎么显示出来? --------------------编程问答-------------------- 建议你先讲个有数据的DataSet,DataSet有两个DataTable。DataSet ds=new DataSet();
ds.write("**.xml");
你看下他的xml结构。就知道了
<?xml version="1.0" standalone="yes"?>
<NewDataSet>
<TableRooms>
<RoomNum>A10001</RoomNum>
<FloorNum>1</FloorNum>
<RoomType>双人标间A</RoomType>
<BedCount>2</BedCount>
<LivesMaxCount>2</LivesMaxCount>
<LivedCount>2</LivedCount>
<Price>149</Price>
<Status>1</Status>
</TableRooms>
<TableRooms>
<RoomNum>A10002</RoomNum>
<FloorNum>1</FloorNum>
<RoomType>双人标间A</RoomType>
<BedCount>2</BedCount>
<LivesMaxCount>2</LivesMaxCount>
<LivedCount>0</LivedCount>
<Price>149</Price>
<Status>0</Status>
</TableRooms>
</NewDataSet>
--------------------编程问答-------------------- ds.WriteXml() --------------------编程问答--------------------
dataset.GetXml().ToString(); --------------------编程问答--------------------
try
{
DataSet ds = new DataSet();
ds.ReadXml(path);
return ds;
}
catch (Exception e)
{
throw e;
}
补充:.NET技术 , C#