C# 读取xml到dataset

fnaiyj123 2009-05-12 11:11:47
xml文档如下:

<?xml version="1.0" encoding="utf-8" ?>
<root>
<Item>
<Id>49b0d9b4ca394daaa4dc3caebd5ae48d</Id>
<Name>项目1</Name>
<Description>11111</Description>
<upperNode>root</upperNode>
<NodeLevel>0</NodeLevel>
<child>
<SecurityObject>
<Id>49b0d9brta394daaa4dc3caebd5ae48d</Id>
<Name>保障对象</Name>
<Description>222</Description>
<upperNode>itme</upperNode>
<NodeLevel>1</NodeLevel>
<Child1>

</Child1>
</SecurityObject>
<Task>
<Id>49b0d9brta394daaa4trecaebd5ae48d</Id>
<Name>保障任务</Name>
<Description>333</Description>
<upperNode>itme</upperNode>
<NodeLevel>1</NodeLevel>
</Task>
<ProtecProgram>
<Id>ghjut9brta394daaa4trecaebd5ae48d</Id>
<Name>保障方案</Name>
<Description>555</Description>
<upperNode>1</upperNode>
<NodeLevel>itme</NodeLevel>
<Child2>
<ProtecFunction>
<Id>49b0d9brsdfg4daaa4trecaebd5ae48d</Id>
<Name>保障功能</Name>
<Description>6666</Description>
<upperNode>ProtecProgram</upperNode>
<NodeLevel>2</NodeLevel>
</ProtecFunction>
<ProtecTissue>
<Id>49b0d9brsdfgtyuaa4trecaebd5ae48d</Id>
<Name>保障组织</Name>
<Description>888</Description>
<upperNode>ProtecProgram</upperNode>
<NodeLevel>2</NodeLevel>
</ProtecTissue>
<ProtecResources>
<Id>49b0d9brsdfgtyuaa4trecaefd5ae48d</Id>
<Name>保障资源</Name>
<Description>999</Description>
<upperNode>ProtecProgram</upperNode>
<NodeLevel>2</NodeLevel>
</ProtecResources>
</Child2>
</ProtecProgram>
</child>
</Item>
</root>
...全文
349 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
freewind0521 2009-05-13
  • 打赏
  • 举报
回复
dataset自己有读取xml的方法readXml
zzxap 2009-05-12
  • 打赏
  • 举报
回复
DataSet ds = new DataSet();
2 using (StringReader sr = new StringReader( xxx ))
3 {
4 ds.ReadXmlSchema(sr);
5 }
6 ds.Tables[0].BeginLoadData();
7
8
9 using (StringReader sr = new StringReader( xxx ))
10 {
11 ds.ReadXml(sr, XmlReadMode.IgnoreSchema);
12 }
13 ds.Tables[0].EndLoadData();
aight 2009-05-12
  • 打赏
  • 举报
回复
DataSet myDS=new DataSet();
myDS.readXml(filePath);[
honey_18 2009-05-12
  • 打赏
  • 举报
回复
dataset.readxml(文件路径)
SlaughtChen 2009-05-12
  • 打赏
  • 举报
回复
学习了
doprojie 2009-05-12
  • 打赏
  • 举报
回复
XmlDocument doc = new XmlDocument();
doc.Load("xml文件路径");
lertulo 2009-05-12
  • 打赏
  • 举报
回复
public class DataSet
{
...
public XmlReadMode ReadXml(string fileName);
...
}
qq34448635 2009-05-12
  • 打赏
  • 举报
回复
你这个XML 文件读到DataSet中 将会有5个表,
十八道胡同 2009-05-12
  • 打赏
  • 举报
回复
dataset.readxml(filepath)
liyunfengleo 2009-05-12
  • 打赏
  • 举报
回复
dataset.readxml
jasondct 2009-05-12
  • 打赏
  • 举报
回复
DataSet myds = new DataSet();
myds .readXml("次XML文件的路径");
fnaiyj123 2009-05-12
  • 打赏
  • 举报
回复
自己已解决。谢谢各位

110,536

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧