快精灵印艺坊 您身边的文印专家
广州名片 深圳名片 会员卡 贵宾卡 印刷 设计教程
产品展示 在线订购 会员中心 产品模板 设计指南 在线编辑
 首页 名片设计   CorelDRAW   Illustrator   AuotoCAD   Painter   其他软件   Photoshop   Fireworks   Flash  

 » 彩色名片
 » PVC卡
 » 彩色磁性卡
 » 彩页/画册
 » 个性印务
 » 彩色不干胶
 » 明信片
   » 明信片
   » 彩色书签
   » 门挂
 » 其他产品与服务
   » 创业锦囊
   » 办公用品
     » 信封、信纸
     » 便签纸、斜面纸砖
     » 无碳复印纸
   » 海报
   » 大篇幅印刷
     » KT板
     » 海报
     » 横幅

.Net FrameWork SDK文档的例子演示

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


返回类别: 教程
上一教程: asp+中常用的NameSpace的讲解
下一教程: C#中数据库操作

您可以阅读与" .Net FrameWork SDK文档的例子演示"相关的教程:
· .Net FrameWork SDK文档的例子演示
· 给Asp.Net初学者的关于继续和多态性的例子
· 在ASP.NET中操作文件的例子(VB)
· 基于.Net Framework的N层分布式应用开发
· .NET Framework 中多语言支持的实现
    微笑服务 优质保证 索取样品