zoukankan      html  css  js  c++  java
  • 如何将一个XML的字符串加载到DataSet中

    如题
    <News>
    <NewsCols>
       <Title></Title>
       <Content></Content>
    </NewsCols>
    </News>
    上面表现为字符串,怎样加载到DataSet中
    ---------------------------------------------------------------
    DataSet.ReadXml() 
    base on .Net 2.0
    ---------------------------------------------------------------
    Something like
    string s = ".........";
    System.IO.StringReader reader = new System.IO.StringReader (s);
    DataSet ds = new DataSet();
    ds.ReadXml(reader);
    ---------------------------------------------
    string str=@"<News>
    <NewsCols>
    <Title></Title>
    <Content></Content>
    </NewsCols>
    </News>";
    //Transfer xml string to DataSet
    string NewLine = System.Environment.NewLine;
    string s = str.Replace(NewLine,""); 
    System.IO.StringReader reader = new System.IO.StringReader(s);
    DataSet ds=new DataSet();
    ds.ReadXml(reader as System.IO.TextReader);
    reader.Close();

  • 相关阅读:
    django 如何重用app
    vim常用命令
    linux find grep
    linux su su-的区别
    linux定时任务crontab
    linux shell的单行多行注释
    python字符串的截取,查找
    gdb调试
    python字符转化
    python读写文件
  • 原文地址:https://www.cnblogs.com/timy/p/1738428.html
Copyright © 2011-2022 走看看