国产探花免费观看_亚洲丰满少妇自慰呻吟_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ā)表
主站蜘蛛池模板: 扎赉特旗| 南木林县| 镇平县| 平湖市| 建水县| 海南省| 安顺市| 桦甸市| 普安县| 沙洋县| 大姚县| 禹州市| 北碚区| 宁武县| 江油市| 齐河县| 昌乐县| 山东省| 海门市| 灵武市| 大邑县| 什邡市| 论坛| 临沂市| 蓝山县| 台南市| 虹口区| 家居| 七台河市| 芦溪县| 南昌县| 霞浦县| 太保市| 仪征市| 琼海市| 江达县| 民丰县| 航空| 达孜县| 水富县| 萍乡市|