人人做人人澡人人爽欧美,国产主播一区二区,久久久精品五月天,羞羞视频在线观看免费

當前位置:蘿卜系統下載站 > 技術開發教程 > 詳細頁面

.Net FrameWork SDK文檔的例子演示

.Net FrameWork SDK文檔的例子演示

更新時間:2022-09-04 文章作者:未知 信息來源:網絡 閱讀次數:

XmlDocument.CreateAttribute 效果演示

using System;
using System.IO;
using System.Xml;

namespace CreateAttribute
{
 /// <summary>
 /// Class1 的摘要說明。
 /// </summary>
 class Class1
 {
  /// <summary>
  /// 應用程序的主入口點。
  /// </summary>
  [STAThread]
  static void Main(string[] args)
  {
   //
   // TODO: 在此處添加代碼以啟動應用程序
   //
   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 的摘要說明。
 /// </summary>
 class Class1
 {
  /// <summary>
  /// 應用程序的主入口點。
  /// </summary>
  [STAThread]
  static void Main(string[] args)
  {
   //
   // TODO: 在此處添加代碼以啟動應用程序
   //
   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


溫馨提示:喜歡本站的話,請收藏一下本站!

本類教程下載

系統下載排行

網站地圖xml | 網站地圖html
主站蜘蛛池模板: 张北县| 芦山县| 两当县| 和顺县| 顺义区| 溧水县| 洪泽县| 松溪县| 赣榆县| 敖汉旗| 长治县| 班戈县| 岳阳县| 绍兴县| 永和县| 东乌| 尼木县| 岐山县| 巫溪县| 横山县| 老河口市| 新河县| 祁门县| 江北区| 呼伦贝尔市| 义马市| 子长县| 阳城县| 阜南县| 克东县| 梁山县| 德昌县| 彭阳县| 天镇县| 平乡县| 广安市| 许昌市| 连城县| 凌海市| 定日县| 永修县|