乡下人产国偷v产偷v自拍,国产午夜片在线观看,婷婷成人亚洲综合国产麻豆,久久综合给合久久狠狠狠9

  • <output id="e9wm2"></output>
    <s id="e9wm2"><nobr id="e9wm2"><ins id="e9wm2"></ins></nobr></s>

    • 分享

      .net中XML的簡(jiǎn)單應(yīng)用 - - CSDN技術(shù)中心

       suweixin 2011-01-14

      .net XML

      1.XML是一種提供數(shù)據(jù)格式描述的標(biāo)記語(yǔ)言。其自描述性使其非常適應(yīng)于不同應(yīng)用間的數(shù)據(jù)交換,而且這種交換不以預(yù)先定義的以組數(shù)據(jù)結(jié)構(gòu)為前提!

      eg:

        <?xml version="1.0" encoding="utf-8"?>
      <root>
        <course_information>
          <courseName>操作系統(tǒng)</courseName>
          <courseTeacher>鄒</courseTeacher>
          <coursePath>Database.aspx</coursePath>
          <courseAddTime>2006-7-1</courseAddTime>
        </course_information>
        <course_information>
          <courseName>數(shù)據(jù)庫(kù)系統(tǒng)原理</courseName>
          <courseTeacher>胡</courseTeacher>
          <coursePath>Database.aspx</coursePath>
          <courseAddTime>2006-7-2</courseAddTime>
        </course_information>
        <course_information>
          <courseName>數(shù)據(jù)結(jié)構(gòu)</courseName>
          <courseTeacher>李</courseTeacher>
          <coursePath>Database.aspx</coursePath>
          <courseAddTime>2006-7-30</courseAddTime>
        </course_information>
      </root> 

      2.編輯XML文檔

        先要把course_information.xml讀入內(nèi)存中,形成一棵DOM樹(shù),然后找到所要插入的父節(jié)點(diǎn),添加一個(gè)新的

      節(jié)點(diǎn),添加一個(gè)新的節(jié)點(diǎn),也就是XML文檔的一個(gè)新的元素。最后把內(nèi)存中的DOM樹(shù)保存為一個(gè)XML文檔。

      eg:

      添加新節(jié)點(diǎn):

       string st="Database.aspx";
         DateTime date1=DateTime.Now;
         string date=date1.ToString("d");
         XmlDocument xmlDoc=new XmlDocument();
         xmlDoc.Load(file);
         XmlNode root=xmlDoc.SelectSingleNode("root");//select the root node;
         XmlElement course=xmlDoc.CreateElement("course_information");
         XmlElement name=xmlDoc.CreateElement("courseName");
         name.InnerText=this.TextBox1.Text;
         XmlElement teacher=xmlDoc.CreateElement("courseTeacher");
         teacher.InnerText=this.TextBox2.Text;
         XmlElement path=xmlDoc.CreateElement("coursePath");
         path.InnerText=st;
         XmlElement addTime=xmlDoc.CreateElement("courseAddTime");
         addTime.InnerText=date;
         course.AppendChild(name);
         course.AppendChild(teacher);
         course.AppendChild(path);
         course.AppendChild(addTime);
         root.AppendChild(course);
         xmlDoc.Save(file);
         xmlDoc=null;

      刪除節(jié)點(diǎn):

      string filename=Server.MapPath(@".\XML\course_information.xml");
          XmlDocument xmlDoc=new XmlDocument();
          xmlDoc.Load(filename);
          string name=this.TextBox1.Text.ToString();
          XmlNode oldNode=xmlDoc.SelectSingleNode("root/course_information[courseName='"+name+"']");
          XmlNode root=xmlDoc.SelectSingleNode("root");
          root.RemoveChild(oldNode);
          xmlDoc.Save(filename);
          xmlDoc=null;
          dt=op.ReadXml(filename);
          dv=dt.DefaultView;
          BindGrid();//綁定到DataGrid

       

        本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶(hù)發(fā)布,不代表本站觀點(diǎn)。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購(gòu)買(mǎi)等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊一鍵舉報(bào)。
        轉(zhuǎn)藏 分享 獻(xiàn)花(0

        0條評(píng)論

        發(fā)表

        請(qǐng)遵守用戶(hù) 評(píng)論公約