国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 編程 > .NET > 正文

.Net FrameWork SDK文檔的例子演示

2024-07-10 12:58:51
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友
xmldocument.createattribute 效果演示

using system;
using system.io;
using system.xml;

namespace createattribute
{
 /// <summary>
 /// class1 的摘要說(shuō)明。
 /// </summary>
 class class1
 {
  /// <summary>
  /// 應(yīng)用程序的主入口點(diǎn)。
  /// </summary>
  [stathread]
  static void main(string[] args)
  {
   //
   // todo: 在此處添加代碼以啟動(dòng)應(yīng)用程序
   //
   xmldocument doc = new xmldocument();
   doc.loadxml("<book genre='novel' isbn='1-861001-57-5'>" +
    "<title>pride and prejudice</title>" +
    "</book>");

   //create an attribute.
   xmlattribute attr = doc.createattribute("publisher");
   attr.value = "worldwide publishing";
         
   //add the new node to the document.
   doc.documentelement.setattributenode(attr);
       
   console.writeline("display the modified xml...");       
   doc.save(console.out);
  }
 }
}


效果如下:
display the modified xml...
<?xml version="1.0" encoding="gb2312"?>
<book genre="novel" isbn="1-861001-57-5" publisher="worldwide publishing">
  <title>pride and prejudice</title>
</book>press any key to continue

xmldocument.createnode 方法效果演示

using system;
using system.xml;

namespace createnode
{
 /// <summary>
 /// class1 的摘要說(shuō)明。
 /// </summary>
 class class1
 {
  /// <summary>
  /// 應(yīng)用程序的主入口點(diǎn)。
  /// </summary>
  [stathread]
  static void main(string[] args)
  {
   //
   // todo: 在此處添加代碼以啟動(dòng)應(yīng)用程序
   //
   xmldocument doc = new xmldocument();
   doc.loadxml("<book>" +
    "  <title>oberon's legacy</title>" +
    "  <price>5.95</price>" +
    "</book>");
 
   // create a new element node.
   xmlnode newelem;
   newelem = doc.createnode(xmlnodetype.element, "pages", ""); 
   newelem.innertext = "290";
    
   console.writeline("add the new element to the document...");
   xmlelement root = doc.documentelement;
   root.appendchild(newelem);
    
   console.writeline("display the modified xml document...");
   console.writeline(doc.outerxml);
  }
 }
}

效果:
add the new element to the document...
display the modified xml document...
<book><title>oberon's legacy</title><price>5.95</price><pages>290</pages></book>

press any key to continue


發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 舒兰市| 宁化县| 台江县| 承德县| 土默特左旗| 滦平县| 万州区| 九江市| 通城县| 宁乡县| 尚义县| 济源市| 陈巴尔虎旗| 怀宁县| 平阳县| 沙洋县| 曲阳县| 富锦市| 饶阳县| 敖汉旗| 怀安县| 新河县| 左贡县| 青州市| 曲阜市| 沧源| 乐昌市| 洛川县| 长治县| 讷河市| 南昌市| 旌德县| 滨海县| 双江| 饶平县| 西乌珠穆沁旗| 福安市| 安阳市| 冀州市| 海安县| 邵阳县|