日期:2014-05-17  浏览次数:21081 次

asp.net读取Xml文件到DataSet,以及DataSet保存为Xml,利用自带的强大功能
<music>
  <song>
    <artist>The Chi-lites</artist>
    <genre>Soul</genre>
    <album>A lonely man</album>
    <year>1972</year>
  </song>
  <song>
    <artist>Babyface</artist>
    <genre>R&B</genre>
    <album>unknown</album>
    <year></year>
  </song>
  <song>
    <artist>Babyface</artist>
    <genre>R&B</genre>
    <album>The essential babyface</album>
    <year>2001</year>
  </song>
  <song>
    <artist>Babyface</artist>
    <genre>R&B</genre>
    <album>Grown and sexy</album>
    <year>2005</year>
  </song>
  <song>
    <artist>Maria Arredondo</artist>
    <genre>Pop</genre>
    <album>Not going under</album>
    <year>2004</year>
  </song>
  <song>
    <artist>Leona Lewis</artist>
    <genre>Pop</genre>
    <album>Unknown</album>
    <year>2008</year>
  </song>
  <song>
    <artist>Usher</artist>
    <genre>R&B</genre>
    <album>Usher</album>
    <year>2008</year>
  </song>
  <song>
    <artist>Christina Aguilera</artist>
    <genre>Blues</genre>
    <album>Back to basics</album>
    <year>2004</year>
  </song>
  <song>
    <artist>Sting</artist>
    <genre>Pop</genre>
    <album>Shape of my heart</album>
    <year></year>
  </song>
</music>
            DataSet ds = new DataSet();
            TextReader reader = new StringReader(@"
                        <music>
                          <song>
                            <artist>The Chi-lites</artist>
                            <genre>Soul</genre>
                            <album>A lonely man</album>
                            <year>1972</year>
                          </song>
                          <song>
                            <artist>Babyface</artist>
                            <genre>R&B</genre>
                            <album>unknown</album>
                            <year></year>
                          </song>
                          <song>
                            <artist>Babyface</artist>
                            <genre>R&B</genre>
                            <album>The essential babyface</album>
                            <year>2001</year>
                          </song>
                          <song>
                            <artist>Babyface</artist>
                            <genre>R&B</genre>
                            <album>Grown and sexy</album>
                            <year>2005</year>
                          </song>
                          <song>
                            <artist>Maria Arredondo</artist>
                            <genre>Pop</genre>
                            <album>Not going under</album>
                            <year>2004</year>
                          </song>
                          <song>
                            <artist>Leona Lewis</artist>
                            <genre>Pop</genre>
                            <album>Unknown</album>
                            <year>2008</year>
                          </song>